public virtual async Task <APIResult> Add(A model, Y userID, bool isCommit = true) { D entity = AddMapping(model); var pkType = default(Y); if (pkType is Guid) { if ((entity.ID as Guid?).IsNullOrEmpty()) { entity.ID = (Y)TypeDescriptor.GetConverter(typeof(Y)).ConvertFromInvariantString(Guid.NewGuid().ToString()); } } if (entity is ITableEntity <Y> ) { (entity as ITableEntity <Y>).CreateBy = userID; (entity as ITableEntity <Y>).CreateDT = DateTime.Now; } uow.Repository <D>().Add(entity); if (isCommit) { await uow.SaveChangesAsync(); } return(new APIResult { Data = entity.ID, Message = Messages.Ok }); }
public virtual async Task <APIResult> Add(A model, Y userId, bool isCommit = true) { D entity = AddMapping(model, userId); _uow.Repository <D>().Add(entity); if (isCommit) { await _uow.SaveChangesAsync(); } return(new APIResult { Data = entity.Id, Message = Messages.Ok }); }
public async Task Add(SysAutoCodeLog entity, bool isCommit = true) { entity.Id = Guid.NewGuid(); _uow.Repository <SysAutoCodeLog>().Add(entity); if (isCommit) { await _uow.SaveChangesAsync(); } }
/// <summary> /// The process of registering the file information in the database /// </summary> /// <param name="entityList"></param> /// <param name="userID"></param> /// <param name="isCommit"></param> /// <returns></returns> public async Task Add(IList <FileDto> modelList, Guid userID, bool isCommit = true) { foreach (var model in modelList) { Domain.File entity = Mapper.Map <Domain.File>(model); entity.ID = Guid.NewGuid(); entity.CreateBy = userID; entity.CreateDT = DateTime.Now; uow.Repository <Domain.File>().Add(entity); } if (isCommit) { await uow.SaveChangesAsync(); } }