public ActionResult Create(BorrowerAndCategories baci) { if (new Auth((BorrowerWithUser)Session["User"]).HasAdminPermission()) { baci.Categories = CategoryService.GetCategories(); if (ModelState.IsValid && (baci.CatergoryId == 1 || baci.CatergoryId == 2 || baci.CatergoryId == 3 || baci.CatergoryId == 4)) { if (!BorrowerService.BorrowerExists(baci.Borrower.PersonId)) { borrower b = new borrower(); b = baci.Borrower; b.CategoryId = baci.CatergoryId; BorrowerService.StoreBorrower(b); TempData["Alert"] = AlertView.Build("Låntagare " + baci.Borrower.FirstName + " " + baci.Borrower.LastName + " skapad.", AlertType.Success); return(Redirect("Start")); } baci.PushAlert(AlertView.Build("Detta personnumret är redan registrerat hos oss", AlertType.Danger)); return(View(baci)); } return(View(baci)); } return(Redirect("/Error/Code/403")); }
public ActionResult Borrower(string id) { Auth _auth = new Auth((BorrowerWithUser)Session["User"]); if (_auth.HasAdminPermission()) { if (!BorrowerService.BorrowerExists(id)) { return(Redirect("/Error/Code/404")); } if (UserService.BorrowerIsUser(_auth.LoggedInUser, id)) { return(Redirect("/User/GetAcountInfo")); } return(View(BorrowerService.GetBorrowerWithBorrows(id))); } return(Redirect("/Error/Code/403")); }