public IActionResult Entry(DepartmentViewModel model) { var deaptment = _mapper.Map <Department>(model); bool IsAdded = _departmentManager.Add(deaptment); return(View()); }
public ActionResult Create(DepartmentViewModel dvm) { if (ModelState.IsValid) { var department = new CYBInfracstructure.DataStructure.Entities.Department { DepartmentName = dvm.DepartmentName, IsActive = dvm.IsActive, LocationId = dvm.LocationId, Date = dvm.Date }; _department.Add(department); _department.SaveChanges(); //return Json(new { success = true, messsage = "Saved Successfully" }, JsonRequestBehavior.AllowGet); //FlashMessage.Confirmation("You have been logged in as: {0}"); TempData["Success"] = "Added Successfully!"; return(RedirectToAction("Index")); } var locations = locationManager.GetAll().ToList(); DepartmentViewModel departmentModel = new DepartmentViewModel { Locations = locations }; return(View(departmentModel)); }
public ActionResult Create([Bind(Include = "Id,Name,Code,OrganizationId")] DepartmentViewModel departmentViewMode) { try { if (ModelState.IsValid) { Department department = Mapper.Map <Department>(departmentViewMode); var name = department.Name.Trim(); if (_departmentManager.GetAll().Count(o => o.Name == name) > 0) { ViewBag.Message1 = "Department name already exist."; } if (ViewBag.Message1 == null) { _departmentManager.Add(department); TempData["msg"] = "Information has been saved successfully"; return(RedirectToAction("Index")); } } ViewBag.OrganizationId = new SelectList(_organizationManager.GetAll(), "Id", "Name", departmentViewMode.OrganizationId); return(View(departmentViewMode)); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Departments", "Create"))); } }
public ActionResult AddDepartment(Department department) { if (!ModelState.IsValid) { return(View("AddDepartment")); } _departmentManager.Add(department); return(RedirectToAction("Index")); }
public ActionResult Create(Department department) { if (ModelState.IsValid) { _iDepartmentManager.Add(department); return(RedirectToAction(nameof(Index))); } return(View(department)); }
public ActionResult Create(DepartmentModel model) { if (ModelState.IsValid) { _departmentManager.Add(model); } else { return(View("Create", model)); } return(RedirectToAction("Index", new { saved = "y" })); }
public ActionResult Create([Bind(Include = "Id,Name")] DepartmentViewModel departmentViewModel) { if (ModelState.IsValid) { Department department = Mapper.Map <Department>(departmentViewModel); _departmentManager.Add(department); TempData["Message"] = "Department is save successfully!"; return(RedirectToAction("Index")); } return(View(departmentViewModel)); }
public IActionResult Create(DepartmentViewModel departmentViewModel) { if (ModelState.IsValid) { var department = _mapper.Map <Department>(departmentViewModel); try { if (_departmentManager.Add(department)) { ViewBag.Message = "Department Save succesfully"; ModelState.Clear(); } else { ViewBag.Message = "Department Save failed"; } } catch (Exception e) { ViewBag.DepartmentExistMessage = e.Message; } return(View()); //var department = _mapper.Map<Department>(departmentViewModel); //if (_departmentRepository.IsDepartmentNameExist(department.DepartmentName)) //{ // if (_departmentRepository.IsDepartmentCodeExist(department.DepartmentCode)) // { // bool isSaved = _departmentRepository.Add(department); // if (isSaved) // { // ViewBag.Message = "Department Saved Successfully.."; // } // } //} //else //{ // ViewBag.DepartmentNameExistMessage = "Department Name Exist"; // ViewBag.DepartmentCodeExistMessage = "Department Code Exist"; //} } return(View()); }
public ActionResult Create([Bind(Include = "DepartmentID,OrganizationBranchID,DepartmentName")] Department department) { if (ModelState.IsValid) { //db.Departments.Add(department); //db.SaveChanges(); _departmentManager.Add(department); return(RedirectToAction("Index")); } var organizationBranchList = _organizationBranchManager.GetAll(); ViewBag.OrganizationBranchID = new SelectList(organizationBranchList, "OrganizationBranchID", "OrganizationBranchName"); return(View(department)); }
public ActionResult Create(DepartmentViewModel departmentVM) { try { Department department = new Department(); department.Name = departmentVM.Name; department.OrganaizationId = departmentVM.OrganaizationId; bool isSaved = _departmentManager.Add(department); if (isSaved) { TempData["msg"] = "Department Save Successfully"; } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult AddNewDepartment(Department model) { try { if (ModelState.IsValid) { var result = _iDepartmentManager.Add(model); if (result) { TempData["Message"] = "Saved Successfully!"; } TempData["Message"] = "Failed to save"; } return(View()); } catch (Exception exception) { TempData["Error"] = exception.Message + "</br>System Error : " + exception?.InnerException?.Message; return(View()); } }