예제 #1
0
        public override bool DeleteData(int id, out Notification notification)
        {
            notification = new Notification {
                Type = NotificationType.Success
            };

            try
            {
                using (var Context = CreateContext())
                {
                    DefectsGroup unit = Context.DefectsGroup.FirstOrDefault(o => o.DefectGroupID == id);

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

                    Context.DefectsGroup.Remove(unit);
                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                notification = new Notification()
                {
                    Type = NotificationType.Error, Message = ex.Message
                };
                return(false);
            }
        }
예제 #2
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);
            }
        }
예제 #3
0
 public void DTO2DB_CheckListGroup(DTO.DefectsGroupDTO dto, ref DefectsGroup db)
 {
     AutoMapper.Mapper.Map <DTO.DefectsGroupDTO, DefectsGroup>(dto, db);
 }