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 UserProfile(string id) { if (User.Identity.IsAuthenticated) { try { SiteUser siteUser = SiteUserManager.GetSiteUserById(id); if (siteUser == null) { throw new Exception(); } ViewBag.PhoneNumber = siteUser.ApplicationUser.PhoneNumber.Substring(4); try { string PictureUID = SiteUserManager.GetPictureUIDById(id); if (PictureUID == null) { throw new Exception(); } ViewBag.Picture = "/Images/Uploaded/Source/" + PictureUID; } catch (Exception) { ViewBag.Picture = "/Images/Default/anonym.png"; } return(View(siteUser)); } catch (Exception) { return(RedirectToAction("Index", "Home")); } } return(RedirectToAction("Index", "Home")); }
public ActionResult Edit(string id) { if (User.Identity.IsAuthenticated && ((User.IsInRole("User") && id == User.Identity.GetUserId()) || User.IsInRole("Admin"))) { try { SiteUser siteUser = SiteUserManager.GetSiteUserById(id); string picture; string phoneNumber = siteUser.ApplicationUser.PhoneNumber.Substring(4); try { string PictureUID = SiteUserManager.GetPictureUIDById(id); if (PictureUID == null) { throw new Exception(); } picture = "/Images/Uploaded/Source/" + PictureUID; } catch (Exception) { picture = null; } return(View(new EditUserViewModel { PictureName = picture, Surname = siteUser.Surname, Name = siteUser.Name, FathersName = siteUser.FathersName, Email = siteUser.ApplicationUser.Email, PhoneNumber = phoneNumber, DateOfBirth = siteUser.DateOfBirth })); } catch (Exception) { return(RedirectToAction("Index", "Home")); } } return(RedirectToAction("Index", "Home")); }
public ActionResult DeleteUser(string id) { if (User.Identity.IsAuthenticated && User.IsInRole("Admin")) { SiteUser siteUser = SiteUserManager.GetSiteUserById(id); if (siteUser == null) { return(RedirectToAction("Index", "Home")); } ViewBag.SNF = String.Format("{0} {1} {2}", siteUser.Surname, siteUser.Name, siteUser.FathersName); return(View()); } return(RedirectToAction("Index", "Home")); }