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