public ActionResult Apply(string id) { if (User.Identity.IsAuthenticated) { List <Privilege> privileges = StatementManager.GetAllPrivileges(); List <Group> groups = StatementManager.GetAllGroups(); List <Kindergarten> Kindergartens = KindergartenManager.GetKindergartens().ToList(); AddStatementViewModel model = new AddStatementViewModel { }; model.Privileges = new List <PrivilegesInnerViewModel> { }; model.Groups = new List <string> { }; for (int i = 0; i < privileges.Count; i++) { model.Privileges.Add(new PrivilegesInnerViewModel { Key = privileges[i].Value, Value = false }); } for (int i = 0; i < groups.Count; i++) { model.Groups.Add(groups[i].Value); } model.Kindergartens = new SelectList(Kindergartens, "Id", "Name"); return(View(model)); } 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 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 AddKindergarten(AddKindergartenViewModel model) { if (User.Identity.IsAuthenticated && User.IsInRole("Admin")) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; string password = Guid.NewGuid().ToString("N"); if (ApplicationManager.IsEmailExist(model.Email)) { ModelState.AddModelError("Email", "Такий емейл вже використовується"); return(View(model)); } else { var result = UserManager.Create(user, password); if (result.Succeeded) { KindergartenManager.AddKindergarten(model, user.Id, Server); UserManager.AddToRole(user.Id, "Administrator"); MailCustom.Mail(model.Email, "IStudy password", GetAnswer(model.Email, password)); return(RedirectToAction("Kindergartens", "Admin")); } AddErrors(result); } } return(View(model)); } return(RedirectToAction("Index", "Home")); }
public ActionResult Apply(AddStatementViewModel model) { if (User.Identity.IsAuthenticated && (User.IsInRole("Admin") || User.IsInRole("User"))) { if (ModelState.IsValid) { if (model.Captcha != Session["code"].ToString()) { ModelState.AddModelError("Captcha", "Неправильно введений код перевірки!"); } if (model.Consent == false) { ModelState.AddModelError("Consent", "Потрібне підтвердження!"); } if (ModelState.IsValid) { StatementManager.ApplyStatement(model, User.Identity.GetUserId()); return(RedirectToAction("Index", "Home")); } List <Kindergarten> Kindergartens = KindergartenManager.GetKindergartens().ToList(); model.Kindergartens = new SelectList(Kindergartens, "Id", "Name"); return(View(model)); } } 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 Kindergartens() { if (User.Identity.IsAuthenticated && User.IsInRole("Admin")) { return(View(KindergartenManager.GetKindergartens())); } return(RedirectToAction("Index", "Home")); }
public ActionResult Search(string search, int currentPage = 1) { ViewBag.Type = "MainSearch"; List <KindergartenListItemViewModel> kindergartenListItemViewModels = KindergartenManager.GetFormatKindergartenListViewModel(false, User.Identity.GetUserId(), search, null, null, (currentPage - 1) * 5, 5); ViewBag.CountOfPages = Convert.ToInt32(kindergartenListItemViewModels.Count / 5) + 1; ViewBag.CurrentPage = currentPage; return(View(kindergartenListItemViewModels)); }
public ActionResult MyKindergartens() { if (User.Identity.IsAuthenticated) { ViewBag.Link = "/MyKindergartens"; return(View("Index", KindergartenManager.GetFormatKindergartenListViewModel(true, User.Identity.GetUserId(), null, null, null, -1, -1))); } return(RedirectToAction("Index", "Home")); }
public ActionResult EditShortInfo(string id) { if (User.Identity.IsAuthenticated && ((User.IsInRole("Administrator") && (id == User.Identity.GetUserId())) || User.IsInRole("Admin"))) { EditShortInfoViewModel model = new EditShortInfoViewModel { Id = id, ShortInfo = KindergartenManager.GetKindergartenClaimValue(id, "ShortInfo") }; return(View(model)); } 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(DeleteKindergartenViewModel model) { if (User.Identity.IsAuthenticated && User.IsInRole("Admin")) { if (!ModelState.IsValid) { return(View(model)); } KindergartenManager.DeleteKindergarten(model.Id, Server); return(RedirectToAction("Kindergartens", "Admin")); } 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 EditShortInfo(EditShortInfoViewModel model) { if (User.Identity.IsAuthenticated && ((User.IsInRole("Administrator") && (model.Id == User.Identity.GetUserId())) || User.IsInRole("Admin"))) { if (ModelState.IsValid) { KindergartenManager.AddKindergartenClaimWithDel(model.Id, "ShortInfo", model.ShortInfo); return(RedirectToAction("KindergartenProfile", "Kindergarten", new { id = model.Id })); } else { return(View(model)); } } return(RedirectToAction("Index", "Home")); }
public ActionResult ChangeAvatar(string id, string left, string top, string right, string bottom, string src) { try { if (User.Identity.IsAuthenticated && ((User.IsInRole("Administrator") && (id == User.Identity.GetUserId())) || User.IsInRole("Admin"))) { int left_int = Convert.ToInt32(left.Split(new char[] { '.' })[0]); int top_int = Convert.ToInt32(top.Split(new char[] { '.' })[0]); int right_int = Convert.ToInt32(right.Split(new char[] { '.' })[0]); int bottom_int = Convert.ToInt32(bottom.Split(new char[] { '.' })[0]); string expansion = src.Split(new char[] { '.' }).Last(); string fileName = Guid.NewGuid().ToString() + '.' + expansion; if (right_int > left_int && bottom_int > top_int) { if ((right_int - left_int) > (bottom_int - top_int)) { right_int--; } if ((right_int - left_int) < (bottom_int - top_int)) { bottom_int--; } if ((right_int - left_int) != (bottom_int - top_int)) { throw new Exception(); } CustomImage.Crop(Image.FromFile(Server.MapPath("~" + src)), new Rectangle(left_int, top_int, right_int - left_int, bottom_int - top_int), fileName, Server); KindergartenManager.AddPreviewPicture(id, fileName, Server); } else { throw new Exception(); } return(RedirectToAction("KindergartenProfile", "Kindergarten", id)); } } catch (Exception) { } return(RedirectToAction("Index", "Home")); }
public ActionResult Edit(EditKindergartenViewModel model, string content) { if (User.Identity.IsAuthenticated && ((User.IsInRole("Administrator") && (model.Id == User.Identity.GetUserId())) || User.IsInRole("Admin"))) { if (ModelState.IsValid) { content = content.Replace("$ENTER$", "\r\n"); List <DescriptionBlock> descriptionBlocks = new List <DescriptionBlock> { }; List <string> blocks = content.Split(new string[] { "$EDGE$" }, StringSplitOptions.None).ToList(); List <string> temp; for (int i = 0; i < blocks.Count; i++) { temp = blocks[i].Split(new string[] { "$SLASH$" }, StringSplitOptions.None).ToList(); switch (temp[0]) { case "text": descriptionBlocks.Add(new DescriptionBlockText { KindergartenId = model.Id, Header = temp[1], Body = temp[2] }); break; case "text-image": descriptionBlocks.Add(new DescriptionBlockTextImage { KindergartenId = model.Id, Image = temp[1], Header = temp[2], Body = temp[3] }); break; } } KindergartenManager.EditKindergarten(descriptionBlocks, model.Id, Server, model); return(RedirectToAction("KindergartenProfile", "Kindergarten", new { id = model.Id })); } else { return(View(model)); } } 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")); }
public ActionResult AdvancedSearch(string search, string searchBy, string sortBy) { ViewBag.Type = "AdvancedSearch"; return(View("Search", KindergartenManager.GetFormatKindergartenListViewModel(false, User.Identity.GetUserId(), search, searchBy, sortBy, -1, -1))); }