public ActionResult SendToEmail(string kindergartenId, int id, string email) { Statement statement = StatementManager.GetStatementById(id); if (User.Identity.IsAuthenticated && ((User.IsInRole("Administrator") && statement.KindergartenId == User.Identity.GetUserId()) || (User.IsInRole("Admin")))) { try { Kindergarten Kindergarten = KindergartenManager.GetKindergartenById(statement.KindergartenId); SiteUser siteUser = SiteUserManager.GetSiteUserById(statement.SiteUserId); StatementListItemViewModel model = new StatementListItemViewModel { Statement = statement, UserPrivileges = StatementManager.GetUserPrivilegesByStatementId(id), KindergartenName = Kindergarten.Name, UserName = siteUser.FullName }; MailCustom.Mail(email, "Заява в електронну чергу #" + model.Statement.Id, GetAnswer(model)); return(RedirectToAction("Statements", "Kindergarten", new { kindergartenId })); } catch { return(RedirectToAction("Statements", "Kindergarten", new { kindergartenId })); } } ; return(RedirectToAction("Index", "Home")); }
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 SendToEmail(int id) { if (User.Identity.IsAuthenticated && (User.IsInRole("Admin") || (User.IsInRole("Administrator")))) { try { Statement statement = StatementManager.GetStatementById(id); if (User.Identity.IsAuthenticated && ((User.IsInRole("Administrator") && statement.KindergartenId == User.Identity.GetUserId()) || (User.IsInRole("Admin")))) { Kindergarten Kindergarten = KindergartenManager.GetKindergartenById(statement.KindergartenId); SiteUser siteUser = SiteUserManager.GetSiteUserById(statement.SiteUserId); StatementListItemViewModel model = new StatementListItemViewModel { Statement = statement, UserPrivileges = StatementManager.GetUserPrivilegesByStatementId(id), KindergartenName = Kindergarten.Name, UserName = String.Format("{0} {1} {2}", siteUser.Surname, siteUser.Name, siteUser.FathersName) }; return(View(model)); } ; } catch (Exception) { } return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Home")); }
public ActionResult ChangeAddress(string id) { if (User.Identity.IsAuthenticated && ((User.IsInRole("Administrator") && (id == User.Identity.GetUserId())) || User.IsInRole("Admin"))) { ChangeAddressViewModel model = new ChangeAddressViewModel { Address = KindergartenManager.GetKindergartenById(id).Address, AltAddress = KindergartenManager.GetKindergartenClaimValue(id, "AltAddress") }; return(View(model)); } return(RedirectToAction("Index", "Home")); }
public ActionResult DeleteKindergarten(string id) { if (User.Identity.IsAuthenticated && User.IsInRole("Admin")) { Kindergarten Kindergarten = KindergartenManager.GetKindergartenById(id); if (Kindergarten == null) { return(RedirectToAction("Index", "Home")); } return(View(new DeleteKindergartenViewModel { Id = Kindergarten.Id, Name = Kindergarten.Name })); } 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")); }