public static bool put_PRO_HoiNghiHoiThao_DangKy(AppEntities db, int ID, DTO_PRO_HoiNghiHoiThao_DangKy item, string Username) { bool result = false; var dbitem = db.tbl_PRO_HoiNghiHoiThao_DangKy.Find(ID); if (dbitem != null) { dbitem.IDNhanVien = item.IDNhanVien; dbitem.IDHoiNghiHoiThao = item.IDHoiNghiHoiThao; dbitem.ModifiedBy = Username; dbitem.ModifiedDate = DateTime.Now; try { db.SaveChanges(); BS_CUS_Version.update_CUS_Version(db, null, "DTO_PRO_HoiNghiHoiThao_DangKy", DateTime.Now, Username); result = true; } catch (DbEntityValidationException e) { errorLog.logMessage("put_PRO_HoiNghiHoiThao_DangKy", e); result = false; } } return(result); }
public IHttpActionResult Post(DTO_PRO_HoiNghiHoiThao_DangKy tbl_PRO_HoiNghiHoiThaoDangKy) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ApplicationUser user = UserManager.FindById(User.Identity.GetUserId()); if (user.StaffID <= 0) { return(BadRequest("Chưa thiết lập nhân sự, không thể đăng ký")); } tbl_PRO_HoiNghiHoiThaoDangKy.IDNhanVien = user.StaffID; DTO_PRO_HoiNghiHoiThao_DangKy result = BS_PRO_HoiNghiHoiThao_DangKy.post_PRO_HoiNghiHoiThao_DangKyCustom(db, tbl_PRO_HoiNghiHoiThaoDangKy, Username); if (result != null) { if (!string.IsNullOrEmpty(result.Error)) { return(BadRequest(result.Error)); } return(CreatedAtRoute("get_PRO_HoiNghiHoiThaoDangKy", new { id = result.ID }, result)); } return(Conflict()); }
public IHttpActionResult Get(int id) { DTO_PRO_HoiNghiHoiThao_DangKy tbl_PRO_HoiNghiHoiThaoDangKy = BS_PRO_HoiNghiHoiThao_DangKy.get_PRO_HoiNghiHoiThao_DangKy(db, id); if (tbl_PRO_HoiNghiHoiThaoDangKy == null) { return(NotFound()); } return(Ok(tbl_PRO_HoiNghiHoiThaoDangKy)); }
public IHttpActionResult Put(int id, DTO_PRO_HoiNghiHoiThao_DangKy tbl_PRO_HoiNghiHoiThaoDangKy) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tbl_PRO_HoiNghiHoiThaoDangKy.ID) { return(BadRequest()); } bool res = BS_PRO_HoiNghiHoiThao_DangKy.put_PRO_HoiNghiHoiThao_DangKy(db, id, tbl_PRO_HoiNghiHoiThaoDangKy, Username); if (res) { return(StatusCode(HttpStatusCode.NoContent)); } else { return(NotFound()); } }
public static DTO_PRO_HoiNghiHoiThao_DangKy post_PRO_HoiNghiHoiThao_DangKy(AppEntities db, DTO_PRO_HoiNghiHoiThao_DangKy item, string Username) { tbl_PRO_HoiNghiHoiThao_DangKy dbitem = new tbl_PRO_HoiNghiHoiThao_DangKy(); if (item != null) { dbitem.IDNhanVien = item.IDNhanVien; dbitem.IDHoiNghiHoiThao = item.IDHoiNghiHoiThao; dbitem.CreatedBy = Username; dbitem.CreatedDate = DateTime.Now; dbitem.ModifiedBy = Username; dbitem.ModifiedDate = DateTime.Now; try { db.tbl_PRO_HoiNghiHoiThao_DangKy.Add(dbitem); db.SaveChanges(); BS_CUS_Version.update_CUS_Version(db, null, "DTO_PRO_HoiNghiHoiThao_DangKy", 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_PRO_HoiNghiHoiThao_DangKy", e); item = null; } } return(item); }
public static DTO_PRO_HoiNghiHoiThao_DangKy post_PRO_HoiNghiHoiThao_DangKyCustom(AppEntities db, DTO_PRO_HoiNghiHoiThao_DangKy item, string Username) { tbl_PRO_HoiNghiHoiThao_DangKy dbitem = new tbl_PRO_HoiNghiHoiThao_DangKy(); if (item != null) { dbitem.IDNhanVien = item.IDNhanVien; dbitem.IDHoiNghiHoiThao = item.IDHoiNghiHoiThao; dbitem.CreatedBy = Username; dbitem.CreatedDate = DateTime.Now; dbitem.ModifiedBy = Username; dbitem.ModifiedDate = DateTime.Now; var hoinghi = db.tbl_PRO_HoiNghiHoiThao.FirstOrDefault(c => c.ID == item.IDHoiNghiHoiThao); if (hoinghi != null) { if (hoinghi.ThoiGianHetHan < DateTime.Now) { item.Error = "Hội nghị đã hết hạn đăng ký!"; return(item); } } try { db.tbl_PRO_HoiNghiHoiThao_DangKy.Add(dbitem); db.SaveChanges(); BS_CUS_Version.update_CUS_Version(db, null, "DTO_PRO_HoiNghiHoiThao_DangKy", 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_PRO_HoiNghiHoiThao_DangKy", e); item = null; } } return(item); }