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 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 RemoveStatement(StatementListItemViewModel model) { try { Statement statement = StatementManager.GetStatementById(model.Statement.Id); if (User.Identity.IsAuthenticated && ((User.IsInRole("User") && statement.SiteUserId == User.Identity.GetUserId()) || (User.IsInRole("Admin") && statement.SiteUserId == User.Identity.GetUserId()))) { StatementManager.RemoveStatement(model.Statement.Id); return(RedirectToAction("MyStatements", "Home")); } } catch { } return(RedirectToAction("MyStatements", "Home")); }
private JsonResult SwitchIsSelected(string statementId, bool isSelected) { int intStatementId = Convert.ToInt32(statementId); Statement statement = StatementManager.GetStatementById(intStatementId); if (User.Identity.IsAuthenticated && User.Identity.GetUserId() == statement.KindergartenId || User.IsInRole("Admin")) { try { StatementManager.SwitchIsSelected(intStatementId, isSelected); return(Json(true)); } catch (Exception) { } } return(Json("Error")); }