コード例 #1
0
        public override bool UpdateData(int userId, int id, ref object dtoItem, out Notification notification)
        {
            DTO.DefectsGroupDTO checkListDTO = ((JObject)dtoItem).ToObject <DTO.DefectsGroupDTO>();

            notification = new Notification {
                Type = NotificationType.Success
            };

            try
            {
                using (var context = CreateContext())
                {
                    DefectsGroup defectsGroup = new DefectsGroup();

                    if (id == 0)
                    {
                        context.DefectsGroup.Add(defectsGroup);
                    }

                    if (id > 0)
                    {
                        defectsGroup = context.DefectsGroup.FirstOrDefault(o => o.DefectGroupID == id);

                        if (defectsGroup == null)
                        {
                            notification = new Notification {
                                Type = NotificationType.Error, Message = "Can't Find Data"
                            };
                            return(false);
                        }
                    }

                    this.converter.DTO2DB_CheckListGroup(checkListDTO, ref defectsGroup);
                    context.SaveChanges();

                    dtoItem = this.GetData(defectsGroup.DefectGroupID, out notification);
                }
                return(true);
            }
            catch (Exception ex)
            {
                notification = new Notification {
                    Type = NotificationType.Error, Message = ex.Message
                };
                return(false);
            }
        }
コード例 #2
0
 public void DTO2DB_CheckListGroup(DTO.DefectsGroupDTO dto, ref DefectsGroup db)
 {
     AutoMapper.Mapper.Map <DTO.DefectsGroupDTO, DefectsGroup>(dto, db);
 }