public override bool UpdateData(int userId, int id, ref object dtoItem, out Notification notification) { DTO.CheckListGroupDTO checkListDTO = ((JObject)dtoItem).ToObject <DTO.CheckListGroupDTO>(); notification = new Notification { Type = NotificationType.Success }; try { using (var context = CreateContext()) { CheckListGroup checkList = new CheckListGroup(); if (id == 0) { context.CheckListGroup.Add(checkList); } if (id > 0) { checkList = context.CheckListGroup.FirstOrDefault(o => o.CheckListGroupID == id); if (checkList == null) { notification = new Notification { Type = NotificationType.Error, Message = "Can't Find Data" }; return(false); } } this.converter.DTO2DB_CheckListGroup(checkListDTO, ref checkList); context.SaveChanges(); dtoItem = this.GetData(checkList.CheckListGroupID, out notification); } return(true); } catch (Exception ex) { notification = new Notification { Type = NotificationType.Error, Message = ex.Message }; return(false); } }
public void DTO2DB_CheckListGroup(DTO.CheckListGroupDTO dto, ref CheckListGroup db) { AutoMapper.Mapper.Map <DTO.CheckListGroupDTO, CheckListGroup>(dto, db); }