public ActionResult KindergartenProfile(string id) { try { Kindergarten Kindergarten = KindergartenManager.GetKindergartenById(id); if (Kindergarten == null) { throw new Exception(); } try { string PictureUID = KindergartenManager.GetPictureUIDById(id); if (PictureUID == null) { throw new Exception(); } ViewBag.Picture = "/Images/Uploaded/Source/" + PictureUID; } catch (Exception) { ViewBag.Picture = "/Images/Default/anonymKindergarten.jpg"; } ViewBag.Blocks = KindergartenManager.GetDescriptionBlocksById(id); return(View(Kindergarten)); } catch (Exception) { return(RedirectToAction("Index", "Home")); } }
public ActionResult Edit(string id) { if (User.Identity.IsAuthenticated && ((User.IsInRole("Administrator") && (id == User.Identity.GetUserId())) || User.IsInRole("Admin"))) { try { Kindergarten Kindergarten = KindergartenManager.GetKindergartenById(id); if (Kindergarten == null) { throw new Exception(); } try { string PictureUID = KindergartenManager.GetPictureUIDById(id); if (PictureUID == null) { throw new Exception(); } ViewBag.Picture = "/Images/Uploaded/Source/" + PictureUID; } catch (Exception) { ViewBag.Picture = "/Images/Default/anonymKindergarten.jpg"; } List <DescriptionBlock> descriptionBlocks = KindergartenManager.GetDescriptionBlocksById(id); EditKindergartenViewModel model = new EditKindergartenViewModel { Id = id, Name = Kindergarten.Name, DescriptionBlocks = descriptionBlocks }; return(View(model)); } catch (Exception) { return(RedirectToAction("Index", "Home")); } } return(RedirectToAction("Index", "Home")); }