public ActionResult Create(DepartmentViewModels collection) { try { if (ModelState.IsValid) { Department toDB = new Department(); toDB.Active = 1; toDB.DepartmentDescription = collection.DepartmentDescription; toDB.DepartmentId = collection.DepartmentId; toDB.DepartmentName = collection.DepartmentName; departmentBL.InsertDepartment(toDB); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Error."); return(View(collection)); } } catch { ModelState.AddModelError("", "Error."); return(View(collection)); } }
public ApiResponse <DepartmentViewModels> GetAllDepartment() { var apiResponse = new ApiResponse <DepartmentViewModels>(); try { var listDepartment = new List <DepartmentViewModels>(); var getDepartment = Utils.GetDepartment(_clientContext); getDepartment?.ForEach(x => { var departmentViewModel = new DepartmentViewModels { Id = x.Id, Code = x.Code, Title = x.Title }; listDepartment.Add(departmentViewModel); }); apiResponse.Content = listDepartment; return(apiResponse); } catch (Exception e) { apiResponse.ErrorType = 400; apiResponse.ErrorMessage = new [] { e.Message }; return(apiResponse); } }
public ActionResult AddInformationEmp(int page, string sid) { if (page != 99) { return(HttpNotFound()); } GetDepartment(); GetChoice_ID_Position(); GetChoice_TypeEmployment(); GetChoice_Age(); GetChoice_ServiceYears(); GetChoice_Age(); GetChoice_Career(); GetChoice_Education(); GetChoice_Gender(); bool b1 = string.IsNullOrEmpty(sid); if (sid == string.Empty || b1 == true) { return(HttpNotFound()); } int[] code = GetCode(sid); int x = 2; x = code[0]; int chkSection = 0; var engageid = code[1]; var currentUrl = string.Empty; var fullUrl = this.Url.Action("AddInformationEmp", "AddEngagementEN", null, this.Request.Url.Scheme); currentUrl = GetUrl(engageid); if (currentUrl == string.Empty) { SaveCurrentUrl(fullUrl, engageid); } chkSection = chkInputData(engageid, 1); switch (x) { case 0: //ยังไม่ได้ทำแบบทดสอบ break; case 1: //ทำแบบทดสอบเรียบร้อยแล้ว break; default: //2 คือเลข Code ไม่ถูกต้อง return(HttpNotFound()); } var viewModel = new DepartmentViewModels() { Encript_ID = sid, StatusAccept = x, engagepersonal_ID = engageid, Section = chkSection }; return(View(viewModel)); }
public ActionResult Edit(int id) { Department department = departmentBL.GetDepartmentById(id); DepartmentViewModels model = new DepartmentViewModels(); model = new DepartmentViewModels(); model.Active = Convert.ToBoolean(department.Active); model.DepartmentDescription = department.DepartmentDescription; model.DepartmentId = department.DepartmentId; model.DepartmentName = department.DepartmentName; return(View(model)); }
public ActionResult departmentUpdate(DepartmentViewModels data) { if (ModelState.IsValid) { DepartmentBussines.GetDepartmentResponse request = new DepartmentBussines.GetDepartmentResponse() { Department = data.Department }; result = DepartmentBussines.Update.Department(request).Message; } return(RedirectToAction("departmentView", new { successful = true, ResultAction = "All Changes was successful" })); }
// GET: Department #region Views public ActionResult departmentView(bool successful = false, string ResultAction = "") { ViewBag.Title = "Department"; ViewBag.successful = successful; ViewBag.Message = ResultAction; var BussinesData = DepartmentBussines.Select.GetDepartmentList(); var model = new DepartmentViewModels() { Error = BussinesData.Error, DepartmentList = BussinesData.DepartmentList }; return(View(model)); }
public ActionResult departmentUpdate(int id) { ViewBag.Title = "Update Department"; ViewBag.Message = ""; DepartmentBussines.GetDepartmentRequest request = new DepartmentBussines.GetDepartmentRequest() { DepartmentID = id }; Department d = DepartmentBussines.Select.GetDepartment(request).Department; var model = new DepartmentViewModels() { Department = d }; return(PartialView(model)); }
public ActionResult Index() { List <DepartmentViewModels> listModels = new List <DepartmentViewModels>(); DepartmentViewModels model = new DepartmentViewModels(); List <Department> fromDB = departmentBL.GetAllDepartments(); foreach (Department item in fromDB) { model = new DepartmentViewModels(); model.Active = Convert.ToBoolean(item.Active); model.DepartmentDescription = item.DepartmentDescription; model.DepartmentId = item.DepartmentId; model.DepartmentName = item.DepartmentName; listModels.Add(model); } return(View(listModels)); }