public static DTO_CAT_Tags post_CAT_Tags(AppEntities db, DTO_CAT_Tags item, string Username) { tbl_CAT_Tags dbitem = new tbl_CAT_Tags(); if (item != null) { dbitem.TenTag = item.TenTag; dbitem.GhiChu = item.GhiChu; 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_CAT_Tags.Add(dbitem); db.SaveChanges(); BS_CUS_Version.update_CUS_Version(db, null, "DTO_CAT_Tags", DateTime.Now, 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_CAT_Tags", e); item = null; } } return(item); }
public static DTO_CAT_Tags toDTO(tbl_CAT_Tags dbResult) { if (dbResult != null) { return(new DTO_CAT_Tags() { ID = dbResult.ID, TenTag = dbResult.TenTag, GhiChu = dbResult.GhiChu, IsDisabled = dbResult.IsDisabled, IsDeleted = dbResult.IsDeleted, CreatedDate = dbResult.CreatedDate, CreatedBy = dbResult.CreatedBy, ModifiedDate = dbResult.ModifiedDate, ModifiedBy = dbResult.ModifiedBy, }); } else { return(null); } }