public static bool put_CAT_KinhPhi(AppEntities db, int ID, DTO_CAT_KinhPhi item, string Username) { bool result = false; var dbitem = db.tbl_CAT_KinhPhi.Find(ID); if (dbitem != null) { dbitem.Code = item.Code; dbitem.Name = item.Name; dbitem.GhiChu = item.GhiChu; dbitem.Sort = item.Sort; dbitem.IsDisabled = item.IsDisabled; dbitem.IsDeleted = item.IsDeleted; dbitem.IsManual = item.IsManual; dbitem.ModifiedBy = Username; dbitem.ModifiedDate = DateTime.Now; try { db.SaveChanges(); BS_CUS_Version.update_CUS_Version(db, null, "DTO_CAT_KinhPhi", DateTime.Now, Username); result = true; } catch (DbEntityValidationException e) { errorLog.logMessage("put_CAT_KinhPhi", e); result = false; } } return(result); }
public IHttpActionResult Get(int id) { DTO_CAT_KinhPhi tbl_CAT_KinhPhi = BS_CAT_KinhPhi.get_CAT_KinhPhi(db, id); if (tbl_CAT_KinhPhi == null) { return(NotFound()); } return(Ok(tbl_CAT_KinhPhi)); }
public IHttpActionResult Post(DTO_CAT_KinhPhi tbl_CAT_KinhPhi) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DTO_CAT_KinhPhi result = BS_CAT_KinhPhi.post_CAT_KinhPhi(db, tbl_CAT_KinhPhi, Username); if (result != null) { return(CreatedAtRoute("get_CAT_KinhPhi", new { id = result.ID }, result)); } return(Conflict()); }
public static DTO_CAT_KinhPhi post_CAT_KinhPhi(AppEntities db, DTO_CAT_KinhPhi item, string Username) { tbl_CAT_KinhPhi dbitem = new tbl_CAT_KinhPhi(); if (item != null) { dbitem.Code = item.Code; dbitem.Name = item.Name; dbitem.GhiChu = item.GhiChu; dbitem.Sort = item.Sort; dbitem.IsDisabled = item.IsDisabled; dbitem.IsDeleted = item.IsDeleted; dbitem.IsManual = item.IsManual; dbitem.CreatedBy = Username; dbitem.CreatedDate = DateTime.Now; dbitem.ModifiedBy = Username; dbitem.ModifiedDate = DateTime.Now; try { db.tbl_CAT_KinhPhi.Add(dbitem); db.SaveChanges(); BS_CUS_Version.update_CUS_Version(db, null, "DTO_CAT_KinhPhi", 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_KinhPhi", e); item = null; } } return(item); }
public IHttpActionResult Put(int id, DTO_CAT_KinhPhi tbl_CAT_KinhPhi) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tbl_CAT_KinhPhi.ID) { return(BadRequest()); } bool result = BS_CAT_KinhPhi.put_CAT_KinhPhi(db, id, tbl_CAT_KinhPhi, Username); if (result) { return(StatusCode(HttpStatusCode.NoContent)); } else { return(NotFound()); } }