Exemplo n.º 1
0
 public static DTO_SYS_Config toDTO(tbl_SYS_Config dbResult)
 {
     if (dbResult != null)
     {
         return(new DTO_SYS_Config()
         {
             ID = dbResult.ID,
             Code = dbResult.Code,
             Name = dbResult.Name,
             Remark = dbResult.Remark,
             Sort = dbResult.Sort,
             IsDisabled = dbResult.IsDisabled,
             IsDeleted = dbResult.IsDeleted,
             CreatedBy = dbResult.CreatedBy,
             ModifiedBy = dbResult.ModifiedBy,
             CreatedDate = dbResult.CreatedDate,
             ModifiedDate = dbResult.ModifiedDate,
             Value = dbResult.Value,
         });
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        public static DTO_SYS_Config post_SYS_ConfigEmail_Template(AppEntities db, DTO_SYS_Config item, string Username)
        {
            var dbitem = db.tbl_SYS_Config.FirstOrDefault(c => c.Code == item.Code && !c.IsDeleted);

            if (dbitem == null)
            {
                dbitem              = new tbl_SYS_Config();
                dbitem.CreatedBy    = Username;
                dbitem.CreatedDate  = DateTime.Now;
                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;
                dbitem.Code         = item.Code;
                db.tbl_SYS_Config.Add(dbitem);
            }
            else
            {
                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;
            }

            item.Email.Subject   = item.Subject;
            item.Email.Body      = item.Body;
            item.Email.EmailList = item.EmailList;

            dbitem.Value = Newtonsoft.Json.JsonConvert.SerializeObject(item.Email);

            if (dbitem != null)
            {
                try
                {
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, null, "post_SYS_ConfigEmail_Template", dbitem.ModifiedDate, Username);

                    item.ID = dbitem.ID;

                    item.CreatedBy   = dbitem.CreatedBy;
                    item.CreatedDate = dbitem.CreatedDate;

                    item.ModifiedBy   = dbitem.ModifiedBy;
                    item.ModifiedDate = dbitem.ModifiedDate;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("post_SYS_ConfigEmail_Template", e);
                    item = null;
                }
            }
            return(item);
        }
Exemplo n.º 3
0
        public static DTO_SYS_Config post_SYS_Config_ThoiGianBaoCaoNSKH(AppEntities db, DTO_SYS_Config item, string Username)
        {
            string sKey   = SYSConfigCode.ThoiGianBaoCaoNSKH.ToString();
            var    dbitem = db.tbl_SYS_Config.FirstOrDefault(c => c.Code == sKey && !c.IsDeleted);

            if (dbitem == null)
            {
                dbitem              = new tbl_SYS_Config();
                dbitem.CreatedBy    = Username;
                dbitem.CreatedDate  = DateTime.Now;
                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;
                dbitem.Code         = sKey;
                db.tbl_SYS_Config.Add(dbitem);
            }
            else
            {
                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;
            }

            dbitem.Value = Newtonsoft.Json.JsonConvert.SerializeObject(item.ThoiGianBaoCaoNSKH);

            if (dbitem != null)
            {
                try
                {
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, null, "post_SYS_Config_ThoiGianBaoCaoNSKH", dbitem.ModifiedDate, Username);

                    item.ID = dbitem.ID;

                    item.CreatedBy   = dbitem.CreatedBy;
                    item.CreatedDate = dbitem.CreatedDate;

                    item.ModifiedBy   = dbitem.ModifiedBy;
                    item.ModifiedDate = dbitem.ModifiedDate;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("post_SYS_Config_ThoiGianBaoCaoNSKH", e);
                    item = null;
                }
            }
            return(item);
        }
Exemplo n.º 4
0
        public static DTO_SYS_Config post_SYS_Config(AppEntities db, DTO_SYS_Config item, string Username)
        {
            tbl_SYS_Config dbitem = new tbl_SYS_Config();

            if (item != null)
            {
                dbitem.Code       = item.Code;
                dbitem.Name       = item.Name;
                dbitem.Remark     = item.Remark;
                dbitem.Sort       = item.Sort;
                dbitem.IsDisabled = item.IsDisabled;
                dbitem.IsDeleted  = item.IsDeleted;
                dbitem.Value      = item.Value;

                dbitem.CreatedBy   = Username;
                dbitem.CreatedDate = DateTime.Now;

                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;


                try
                {
                    db.tbl_SYS_Config.Add(dbitem);
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, null, "DTO_SYS_Config", dbitem.ModifiedDate, Username);


                    item.ID = dbitem.ID;

                    item.CreatedBy   = dbitem.CreatedBy;
                    item.CreatedDate = dbitem.CreatedDate;

                    item.ModifiedBy   = dbitem.ModifiedBy;
                    item.ModifiedDate = dbitem.ModifiedDate;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("post_SYS_Config", e);
                    item = null;
                }
            }
            return(item);
        }