public static DTO_WEB_BaiViet_DanhMuc post_WEB_BaiViet_DanhMuc(AppEntities db, DTO_WEB_BaiViet_DanhMuc item, string Username) { tbl_WEB_BaiViet_DanhMuc dbitem = new tbl_WEB_BaiViet_DanhMuc(); if (item != null) { dbitem.IDDanhMuc = item.IDDanhMuc; dbitem.IDBaiViet = item.IDBaiViet; dbitem.URL = item.URL; dbitem.Sort = item.Sort; dbitem.IsDisabled = item.IsDisabled; dbitem.IsDeleted = item.IsDeleted; dbitem.CreatedBy = Username; dbitem.CreatedDate = DateTime.Now; dbitem.ModifiedBy = Username; dbitem.ModifiedDate = DateTime.Now; try { db.tbl_WEB_BaiViet_DanhMuc.Add(dbitem); db.SaveChanges(); BS_CUS_Version.update_CUS_Version(db, null, "DTO_WEB_BaiViet_DanhMuc", 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_WEB_BaiViet_DanhMuc", e); item = null; } } return(item); }
public static DTO_WEB_BaiViet_DanhMuc toDTO(tbl_WEB_BaiViet_DanhMuc dbResult) { if (dbResult != null) { return(new DTO_WEB_BaiViet_DanhMuc() { IDDanhMuc = dbResult.IDDanhMuc, IDBaiViet = dbResult.IDBaiViet, ID = dbResult.ID, URL = dbResult.URL, Sort = dbResult.Sort, IsDisabled = dbResult.IsDisabled, IsDeleted = dbResult.IsDeleted, CreatedBy = dbResult.CreatedBy, ModifiedBy = dbResult.ModifiedBy, CreatedDate = dbResult.CreatedDate, ModifiedDate = dbResult.ModifiedDate, }); } else { return(null); } }