public override bool UpdateData(int userId, int id, ref object dtoItem, out Notification notification) { DTO.ProductionTeamDto productionTeamDto = ((JObject)dtoItem).ToObject <DTO.ProductionTeamDto>(); notification = new Notification() { Type = NotificationType.Success }; try { using (var context = this.CreateContext()) { ProductionTeam productionTeam = new ProductionTeam(); if (id == 0) { context.ProductionTeam.Add(productionTeam); } if (id > 0) { productionTeam = context.ProductionTeam.FirstOrDefault(o => o.ProductionTeamID == id); if (productionTeam == null) { notification.Message = "Can not found data!"; return(false); } } this.converter.DTO2DB_ProductionTeam(productionTeamDto, ref productionTeam); productionTeam.UpdatedBy = userId; productionTeam.UpdatedDate = System.DateTime.Now; productionTeam.CompanyID = fwFactory.GetCompanyID(userId); context.SaveChanges(); dtoItem = this.GetData(productionTeam.ProductionTeamID, out notification); } return(true); } catch (System.Exception ex) { notification.Type = NotificationType.Error; notification.Message = ex.Message; return(false); } }
public void DTO2DB_ProductionTeam(DTO.ProductionTeamDto dto, ref ProductionTeam db) { AutoMapper.Mapper.Map <DTO.ProductionTeamDto, ProductionTeam>(dto, db); }