public ActionResult AlterBoardTypes(ExpandedBoardTypesDTO objExpandedBoardTypeDTO) { try { if (objExpandedBoardTypeDTO == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var change = context.BoardTypes.Find(objExpandedBoardTypeDTO.Id); //Gets board type to edit if (change == null) { return(HttpNotFound()); } change.BoardCosts = objExpandedBoardTypeDTO.BoardCosts; change.Board_Type = objExpandedBoardTypeDTO.Board_Type; context.SaveChanges(); //Saves changes return(EditBoardTypes()); } catch (Exception ex) { this.AddNotification("", NotificationType.ERROR); ViewBag.Error = ("Error: " + Convert.ToString(ex)); return(View("~/Views/Shared/Error.cshtml")); } }
public ActionResult AddBoardType(ExpandedBoardTypesDTO AddBoardTypeDTO) { try { if (AddBoardTypeDTO == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (context.BoardTypes.Any(x => x.Board_Type == AddBoardTypeDTO.Board_Type)) { this.AddNotification("", NotificationType.ERROR); ViewBag.Error = "Board Type Exists with that Board Type"; return(View("~/Views/Shared/Error.cshtml")); } var e = new BoardType //Creates the new board type { Board_Type = AddBoardTypeDTO.Board_Type, BoardCosts = AddBoardTypeDTO.BoardCosts, }; context.BoardTypes.Add(e); context.SaveChanges(); //saves return(Redirect("Index")); } catch (Exception ex) { this.AddNotification("", NotificationType.ERROR); ViewBag.Error = ("Error: " + Convert.ToString(ex)); return(View("~/Views/Shared/Error.cshtml")); } }
public ActionResult AlterBoardTypes(int Id) { if (Id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var ToBeEdited = context.BoardTypes.Find(Id); //finds board type ExpandedBoardTypesDTO objExpandedBoardTypeDTO = new ExpandedBoardTypesDTO { Board_Type = ToBeEdited.Board_Type, Id = ToBeEdited.Id, BoardCosts = ToBeEdited.BoardCosts }; if (objExpandedBoardTypeDTO == null) { return(HttpNotFound()); } return(View("AlterBoardTypes", objExpandedBoardTypeDTO)); }
// public ActionResult Create() public ActionResult AddBoardType() { ExpandedBoardTypesDTO AddBoardTypeDTO = new ExpandedBoardTypesDTO(); return(View("AddBoardType", AddBoardTypeDTO)); }