public static bool put_CAT_BangGiaKinhPhi(AppEntities db, int ID, DTO_CAT_BangGiaKinhPhi item, string Username) { bool result = false; var dbitem = db.tbl_CAT_BangGiaKinhPhi.Find(ID); if (dbitem != null) { dbitem.IDKinhPhi = item.IDKinhPhi; dbitem.NgayHieuLuc = item.NgayHieuLuc; dbitem.Gia = item.Gia; dbitem.IsDisabled = item.IsDisabled; dbitem.IsDeleted = item.IsDeleted; dbitem.ModifiedBy = Username; dbitem.ModifiedDate = DateTime.Now; try { db.SaveChanges(); BS_CUS_Version.update_CUS_Version(db, null, "DTO_CAT_BangGiaKinhPhi", DateTime.Now, Username); result = true; } catch (DbEntityValidationException e) { errorLog.logMessage("put_CAT_BangGiaKinhPhi", e); result = false; } } return(result); }
public IHttpActionResult Get(int id) { DTO_CAT_BangGiaKinhPhi tbl_CAT_BangGiaKinhPhi = BS_CAT_BangGiaKinhPhi.get_CAT_BangGiaKinhPhi(db, id); if (tbl_CAT_BangGiaKinhPhi == null) { return NotFound(); } return Ok(tbl_CAT_BangGiaKinhPhi); }
public IHttpActionResult Post(DTO_CAT_BangGiaKinhPhi tbl_CAT_BangGiaKinhPhi) { if (!ModelState.IsValid) { return BadRequest(ModelState); } DTO_CAT_BangGiaKinhPhi result = BS_CAT_BangGiaKinhPhi.post_CAT_BangGiaKinhPhi(db, tbl_CAT_BangGiaKinhPhi, Username); if (result != null) { return CreatedAtRoute("get_CAT_BangGiaKinhPhi", new { id = result.ID }, result); } return Conflict(); }
public IHttpActionResult Put(int id, DTO_CAT_BangGiaKinhPhi tbl_CAT_BangGiaKinhPhi) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != tbl_CAT_BangGiaKinhPhi.ID) { return BadRequest(); } bool result = BS_CAT_BangGiaKinhPhi.put_CAT_BangGiaKinhPhi(db, id, tbl_CAT_BangGiaKinhPhi, Username); if (result) return StatusCode(HttpStatusCode.NoContent); else return NotFound(); }
public static DTO_CAT_BangGiaKinhPhi post_CAT_BangGiaKinhPhi(AppEntities db, DTO_CAT_BangGiaKinhPhi item, string Username) { tbl_CAT_BangGiaKinhPhi dbitem = new tbl_CAT_BangGiaKinhPhi(); if (item != null) { dbitem.IDKinhPhi = item.IDKinhPhi; dbitem.NgayHieuLuc = item.NgayHieuLuc; dbitem.Gia = item.Gia; 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_BangGiaKinhPhi.Add(dbitem); db.SaveChanges(); BS_CUS_Version.update_CUS_Version(db, null, "DTO_CAT_BangGiaKinhPhi", 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_BangGiaKinhPhi", e); item = null; } } return(item); }