12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using MTWorkHR.Core.Entities;
- using MTWorkHR.Core.IRepositories.Base;
- using MTWorkHR.Core.UnitOfWork;
- using MTWorkHR.Infrastructure.Data;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- namespace MTWorkHR.Infrastructure.UnitOfWorks
- {
- public class UnitOfWorkLog : IUnitOfWorkLog
- {
- private readonly HRDataContext context;
- public IRepositoryLog<UserLog> UserLog { get; }
- public IRepositoryLog<AuthenticateLog> AuthenticateLog { get; }
- public IRepositoryLog<FileLog> FileLog { get; }
- public IRepositoryLog<RoleLog> RoleLog { get; }
- public IRepositoryLog<SettingLog> SettingLog { get; }
- public IRepositoryLog<SmsLog> SmsLog { get; }
- public UnitOfWorkLog(HRDataContext _context
- , IRepositoryLog<UserLog> userLog
- , IRepositoryLog<AuthenticateLog> authenticateLog
- , IRepositoryLog<FileLog> FileLog
- , IRepositoryLog<RoleLog> RoleLog
- , IRepositoryLog<SettingLog> settingLog
- , IRepositoryLog<SmsLog> SmsLog
- )
- {
- context = _context;
- UserLog = userLog;
- AuthenticateLog = authenticateLog;
- this.FileLog = FileLog;
- this.RoleLog = RoleLog;
- this.SettingLog = settingLog;
- this.SmsLog = SmsLog;
- }
- public async Task<int> CompleteAsync()
- {
- return await context.SaveChangesAsync();
- }
- public object GetRepositoryByName(string name)
- {
- Type type = this.GetType();
- PropertyInfo info = type.GetProperty(name);
- if (info == null)
- throw new Exception(String.Format(
- "A property called {0} can't be accessed for type {1}.",
- name, type.FullName));
- var value = info.GetValue(this, null);
- // value = Convert.ChangeType(value, type);
- return value;
- }
- }
- }
|