public ActionResult ToBook(Guid id) { if (TAuth.IsLogged() && !TAuth.IsAdmin()) { var userID = (string)Session["UserID"]; if (userID == null || id == null) { return(RedirectToAction("Index")); } Spectacle spectacle = repo.GetSpectacle(id); User user = repo.GetUser(Guid.Parse(userID)); Sale sale = new Sale { ID = Guid.Empty, SpectacleID = spectacle.ID, Spectacle = spectacle, UserID = user.ID, User = user, Amount = 2 }; return(View(sale)); } else { return(RedirectToAction("Index")); } }
public JsonResult ToBookConfirm(string saleStr) { bool success = false; string message = "There was an error"; if (TAuth.IsLogged() && !TAuth.IsAdmin()) { try { Sale sale = JsonConvert.DeserializeObject <Sale>(saleStr); sale.ID = Guid.Empty; int ticketsCount = repo.GetSpectacle(sale.SpectacleID).TicketsCount; int allSales = repo.GetAllSales().Where(s => s.SpectacleID == sale.SpectacleID && s.State.Name == "Active").Sum(a => a.Amount); if (sale.Amount <= ticketsCount - allSales) { repo.SaveSale(sale); success = true; message = "OK"; } else { message = string.Format("We have not {0} tickets. We have {1}", sale.Amount, ticketsCount - allSales); } } catch { } } return(Json(new { Success = success, Message = message }, JsonRequestBehavior.AllowGet)); }
public ActionResult Index() { if (TAuth.IsAdmin()) { return(View(repo.GetAllSpectacles())); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult GetSpectacle(Guid id) { if (TAuth.IsAdmin()) { return(View(repo.GetSpectacle(id))); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult AddState() { if (TAuth.IsAdmin()) { return(View()); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult DeleteUser(Guid id) { if (TAuth.IsAdmin()) { return(View(repo.GetUser(id))); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult DeleteConfirmed(Guid id) { if (TAuth.IsAdmin()) { repo.DeleteNotification(id); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult AddNotification(Notification item) { if (TAuth.IsAdmin()) { repo.SaveNotification(item); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult AddSpectacle(Spectacle item) { if (TAuth.IsAdmin()) { repo.SaveSpectacle(item); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult AddRole() { if (TAuth.IsAdmin()) { ViewBag.StateID = new SelectList(repo.GetAllStates(), "ID", "Name"); return(View()); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult AddUser(User item) { if (TAuth.IsAdmin()) { repo.SaveUser(item); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult DeleteSale(Guid id) { if (TAuth.IsLogged() && !TAuth.IsAdmin()) { repo.DeleteSale(id); return(RedirectToAction("UserAllInfo", new { id = Guid.Parse((string)Session["UserID"]) })); } else { return(RedirectToAction("Index")); } }
public ActionResult EditRole(Guid id) { if (TAuth.IsAdmin()) { var role = repo.GetRole(id); ViewBag.StateID = new SelectList(repo.GetAllStates(), "ID", "Name", role.StateID); return(View(role)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult EditNotification(Guid id) { if (TAuth.IsAdmin()) { var notification = repo.GetNotification(id); ViewBag.StateID = new SelectList(repo.GetAllStates(), "ID", "Name", notification.StateID); ViewBag.UserID = new SelectList(repo.GetAllUsers(), "ID", "Name", notification.UserID); return(View(notification)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult EditUser(Guid id) { if (TAuth.IsAdmin()) { var user = repo.GetUser(id); ViewBag.StateID = new SelectList(repo.GetAllStates(), "ID", "Name", user.StateID); ViewBag.RoleID = new SelectList(repo.GetAllRoles(), "ID", "Name", user.RoleID); return(View(user)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult EditSale(Guid id) { if (TAuth.IsAdmin()) { var sale = repo.GetSale(id); ViewBag.UserID = new SelectList(repo.GetAllUsers(), "ID", "Name", sale.UserID); ViewBag.SpectacleID = new SelectList(repo.GetAllSpectacles(), "ID", "Name", sale.SpectacleID); ViewBag.StateID = new SelectList(repo.GetAllStates(), "ID", "Name", sale.StateID); return(View(sale)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult UserAllInfo() { if (TAuth.IsLogged() && !TAuth.IsAdmin()) { var user = repo.GetUser(Guid.Parse((string)Session["UserID"])); var sales = repo.GetAllSales(); UserAllInfoModel model = new UserAllInfoModel { User = user, Sales = sales.Where(s => s.UserID == user.ID && s.State.Name == "Active").ToList() }; return(View(model)); } else { return(RedirectToAction("Index", "Home")); } }