public static bool put_SYS_Config(AppEntities db, int ID, DTO_SYS_Config item, string Username) { bool result = false; var dbitem = db.tbl_SYS_Config.Find(ID); if (dbitem != 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.ModifiedBy = Username; dbitem.ModifiedDate = DateTime.Now; try { db.SaveChanges(); BS_CUS_Version.update_CUS_Version(db, null, "DTO_SYS_Config", dbitem.ModifiedDate, Username); result = true; } catch (DbEntityValidationException e) { errorLog.logMessage("put_SYS_Config", e); result = false; } } return(result); }
public IHttpActionResult Post(DTO_SYS_Config tbl_SYS_Config) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DTO_SYS_Config result = BS_SYS_Config.post_SYS_Config_ThoiGianBaoCaoNSKH(db, tbl_SYS_Config, Username); return(Ok(result)); }
public IHttpActionResult Get() { DTO_SYS_Config tbl_SYS_Config = BS_SYS_Config.get_SYS_Config_ThoiGianBaoCaoNSKH(db); if (tbl_SYS_Config == null) { return(NotFound()); } return(Ok(tbl_SYS_Config)); }
public IHttpActionResult Post(DTO_SYS_Config tbl_SYS_Config) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DTO_SYS_Config result = BS_SYS_Config.post_SYS_ConfigEmail_Template(db, tbl_SYS_Config, Username); return(Ok(result)); }
public IHttpActionResult GetByCode(string code) { DTO_SYS_Config tbl_SYS_Config = BS_SYS_Config.get_SYS_ConfigEmail_Template(db, code); if (tbl_SYS_Config == null) { return(NotFound()); } return(Ok(tbl_SYS_Config)); }
public IHttpActionResult Get() { DTO_SYS_Config tbl_SYS_Config = BS_SYS_Config.get_SYS_Config_Template(db); if (tbl_SYS_Config == null) { return(NotFound()); } return(Ok(tbl_SYS_Config)); }
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); }
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); }
public static DTO_SYS_Config get_SYS_ConfigEmail_Template(AppEntities db, string keyCode) { var obj = db.tbl_SYS_Config.FirstOrDefault(c => c.Code == keyCode && !c.IsDeleted); if (obj == null) { return(new DTO_SYS_Config { Email = new DTO_SYS_ConfigEmail(), Code = keyCode, }); } else { DTO_SYS_Config res = new DTO_SYS_Config { ID = obj.ID, Code = obj.Code, Name = obj.Name, Remark = obj.Remark, Sort = obj.Sort, IsDisabled = obj.IsDisabled, IsDeleted = obj.IsDeleted, CreatedBy = obj.CreatedBy, ModifiedBy = obj.ModifiedBy, CreatedDate = obj.CreatedDate, ModifiedDate = obj.ModifiedDate, Value = obj.Value, Email = new DTO_SYS_ConfigEmail() }; if (!string.IsNullOrEmpty(res.Value)) { res.Email = Newtonsoft.Json.JsonConvert.DeserializeObject <DTO_SYS_ConfigEmail>(res.Value); res.Body = res.Email.Body; res.Subject = res.Email.Subject; res.EmailList = res.Email.EmailList; } return(res); } }
public static DTO_SYS_Config get_SYS_Config_Template(AppEntities db) { string sKey = SYSConfigCode.Template.ToString(); var obj = db.tbl_SYS_Config.FirstOrDefault(c => c.Code == sKey && !c.IsDeleted); if (obj == null) { return(new DTO_SYS_Config { Template = new DTO_SYS_Config_Template() }); } else { DTO_SYS_Config res = new DTO_SYS_Config { ID = obj.ID, Code = obj.Code, Name = obj.Name, Remark = obj.Remark, Sort = obj.Sort, IsDisabled = obj.IsDisabled, IsDeleted = obj.IsDeleted, CreatedBy = obj.CreatedBy, ModifiedBy = obj.ModifiedBy, CreatedDate = obj.CreatedDate, ModifiedDate = obj.ModifiedDate, Value = obj.Value, Template = new DTO_SYS_Config_Template() }; if (!string.IsNullOrEmpty(res.Value)) { res.Template = Newtonsoft.Json.JsonConvert.DeserializeObject <DTO_SYS_Config_Template>(res.Value); } return(res); } }
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); }