public ActionResult Edit(DeptVM poViewModel) { ViewBag.AC_MENU_ID = valMENU.MST_DEPT_EDIT; this.oVAL = new Dept_Validation(poViewModel, this.oDS); this.oVAL.Validate_Edit(); //Add Error if exists for (int i = 0; i < this.oVAL.aValidationMSG.Count; i++) { ModelState.AddModelError(this.oVAL.aValidationMSG[i].VAL_ERRID, this.oVAL.aValidationMSG[i].VAL_ERRMSG); } //End for (int i = 0; i < this.oVAL.aValidationMSG.Count; i++) if (ModelState.IsValid) { this.oCRUD.Update(poViewModel); this.oCRUD.Commit(); if (this.oCRUD.isERR) { TempData["ERRMSG"] = this.oCRUD.ERRMSG; return(RedirectToAction("ErrorSYS", "Error")); } //End if (!this.oCRUD.isERR) { TempData["CRUDSavedOrDelete"] = valFLAG.FLAG_TRUE; return(RedirectToAction("Details", new { id = this.oCRUD.ID })); } return(View(poViewModel)); }
public ActionResult Edit(int? id = null) { ViewBag.AC_MENU_ID = valMENU.MST_DEPT_EDIT; ViewBag.CRUD_type = hlpFlags_CRUDOption.UPDATE; this.oData = oDS.getData(id); if (this.oData == null) { return HttpNotFound(); } return View(this.oData); }
public ActionResult Index(DeptVM vm, string Selected) { DeptService deptService = new DeptService(); vm.Employees = deptService.getEmployeesByDeptNo(Convert.ToInt32(Selected)); vm.Departments = deptService.Departments; return(View(vm)); }
// GET: Dept public ActionResult Index() { DeptService deptServices = new DeptService(); DeptVM deptMV = new DeptVM { Employees = deptServices.Employees, Departments = deptServices.Departments }; return(View(deptMV)); }
public ActionResult Details(int? id = null) { ViewBag.AC_MENU_ID = valMENU.MST_DEPT_DETAILS; ViewBag.CRUD_type = hlpFlags_CRUDOption.VIEW; ViewBag.CRUDSavedOrDelete = TempData["CRUDSavedOrDelete"]; this.oData = oDS.getData(id); if (this.oData == null) { return HttpNotFound(); } return View(this.oData); }
public ActionResult Delete(int? id = null) { //Hardcode return RedirectToAction("Details", new { id = 1 }); //ViewBag.AC_MENU_ID = valMENU.MODULE_DELETE; ViewBag.CRUD_type = hlpFlags_CRUDOption.DELETE; this.oData = oDS.getData(id); if (this.oData == null) { return HttpNotFound(); } return View(this.oData); }
//BL //MAP //Init private void initConstructor(DBMAINContext poDB) { //DBContext this.db = poDB; //VM this.oVM = new DeptVM(); //DS this.oDS = new DeptDS(this.db); //CRUD this.oCRUD = new DeptCRUD(this.db); //BL //MAP } //End initConstructor
public JsonResult Insert(DeptVM departmentVM) { client.DefaultRequestHeaders.Add("Authorization", HttpContext.Session.GetString("JWTToken")); var myContent = JsonConvert.SerializeObject(departmentVM); var buffer = System.Text.Encoding.UTF8.GetBytes(myContent); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); if (departmentVM.Id.Equals(0)) { var result = client.PostAsync("Dept/", byteContent).Result; return(Json(result)); } else { var result = client.PutAsync("Dept/" + departmentVM.Id, byteContent).Result; return(Json(result)); } }
public JsonResult GetById(int Id) { client.DefaultRequestHeaders.Add("Authorization", HttpContext.Session.GetString("JWTToken")); DeptVM departmentVM = null; var responseTask = client.GetAsync("Dept/" + Id); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var json = JsonConvert.DeserializeObject(result.Content.ReadAsStringAsync().Result).ToString(); departmentVM = JsonConvert.DeserializeObject <DeptVM>(json); } else { ModelState.AddModelError(string.Empty, "server error, try after some time"); } return(Json(departmentVM)); }