Exemple #1
0
        public override bool UpdateData(int userId, int id, ref object objItem, out Notification notification)
        {
            notification      = new Notification();
            notification.Type = NotificationType.Success;

            DTO.QCReportDefaultSettingDTO dtoItem = ((Newtonsoft.Json.Linq.JObject)objItem).ToObject <DTO.QCReportDefaultSettingDTO>();

            try
            {
                using (var context = CreateContext())
                {
                    QCReportDefaultSetting dbItem;

                    if (id == 0)
                    {
                        dbItem = new QCReportDefaultSetting();
                        context.QCReportDefaultSetting.Add(dbItem);
                    }
                    else
                    {
                        dbItem = context.QCReportDefaultSetting.FirstOrDefault(o => o.QCReportDefaultSettingID == id);

                        if (dbItem == null)
                        {
                            notification.Type    = NotificationType.Error;
                            notification.Message = "Can not found data!";

                            return(false);
                        }
                    }

                    converter.DTO2DB_QCReportDefaultSetting(dtoItem, ref dbItem);
                    context.SaveChanges();

                    objItem = GetData(dbItem.QCReportDefaultSettingID, out notification).Data;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                notification.Type    = NotificationType.Error;
                notification.Message = Library.Helper.GetInnerException(ex).Message;
            }

            return(true);
        }
Exemple #2
0
 public void DTO2DB_QCReportDefaultSetting(DTO.QCReportDefaultSettingDTO dtoItem, ref QCReportDefaultSetting dbItem)
 {
     AutoMapper.Mapper.Map <DTO.QCReportDefaultSettingDTO, QCReportDefaultSetting>(dtoItem, dbItem);
 }