public ActionResult SetPromotions(int tournamentId, int phaseId) { _tournamentManager.SetPromotions(tournamentId, phaseId); TempData["Alert"] = SetAlert.Set("Poprawnie wykonano działanie!", "Sukces", AlertType.Success); return(RedirectToAction("Manage", new { @tournamentId = tournamentId })); }
public ActionResult SetTaskFlag(int taskId, int tournamentId, bool flag) { _tournamentManager.SetTaskActiveFlag(taskId, flag); TempData["Alert"] = SetAlert.Set("Poprawnie wykonano działanie!", "Sukces", AlertType.Success); return(RedirectToAction("Manage", new { @tournamentId = tournamentId })); }
public static SetAlert Set(string message, string strongMessage, AlertType typeOfAlert) { SetAlert alert = new SetAlert(); alert.Message = message; alert.StrongMessage = strongMessage; switch (typeOfAlert) { case AlertType.Success: alert.TypeOfAlert = "alert-success"; break; case AlertType.Danger: alert.TypeOfAlert = "alert-danger"; break; case AlertType.Info: alert.TypeOfAlert = "alert-info"; break; case AlertType.Warning: alert.TypeOfAlert = "alert-warning"; break; } return alert; }
public ActionResult Solution(SolutionViewModel viewModel) { string userId = User.Identity.GetUserId(); SolutionManager solutionManager; if (viewModel.File != null) { byte[] file = new byte[viewModel.File.ContentLength]; viewModel.File.InputStream.Read(file, 0, file.Length); //zapisujemy plik w postaci bitów solutionManager = new SolutionManager(file, userId, viewModel.TaskId, (CompilerType)viewModel.SelectedLang); } else { solutionManager = new SolutionManager(viewModel.Program, userId, viewModel.TaskId, (CompilerType)viewModel.SelectedLang); } solutionManager.IniclizeManagers(); solutionManager.JavaMainClass = viewModel.JavaMainClassName; HostingEnvironment.QueueBackgroundWorkItem(x => { solutionManager.CheckSolution(); }); TempData["Alert"] = SetAlert.Set("Dziękujemy za przesłanie zgłoszenia! Wynik możesz poznać w sekcji <b>Zgłoszone rozwiązania</b> w menu.", "Sukces", AlertType.Success); return(RedirectToAction("Index", "Home", new { @area = "User" })); }
public ActionResult Register(int tourId) { string userId = User.Identity.GetUserId(); bool isNonRegister = _tournamentManager.IsRegistered(userId, tourId); if (isNonRegister) { bool tryRegister = _tournamentManager.RegisterToTournament(userId, tourId); if (tryRegister) { TempData["Alert"] = SetAlert.Set("Poprawnie zapisano do turnieju!", "Sukces", AlertType.Success); } else { TempData["Alert"] = SetAlert.Set("Wykorzystano limit miejsc!", "Błąd", AlertType.Danger); } } else { TempData["Alert"] = SetAlert.Set("Bierzesz udział już w tym turnieju!", "Błąd", AlertType.Danger); } return(RedirectToAction("Index")); }
public static SetAlert Set(string message, string strongMessage, AlertType typeOfAlert) { SetAlert alert = new SetAlert(); alert.Message = message; alert.StrongMessage = strongMessage; switch (typeOfAlert) { case AlertType.Success: alert.TypeOfAlert = "alert-success"; break; case AlertType.Danger: alert.TypeOfAlert = "alert-danger"; break; case AlertType.Info: alert.TypeOfAlert = "alert-info"; break; case AlertType.Warning: alert.TypeOfAlert = "alert-warning"; break; } return(alert); }
public JsonResult SetConfigure(int Id) { bool result = _tournamentManager.ConfigureSet(Id, true); TempData["Alert"] = SetAlert.Set("Turniej o id: " + Id + " został skonfigurowany.", "Sukcess", AlertType.Success); return(Json(result)); }
public ActionResult EditTournament(EditTournamentViewModel viewModel) { var tour = new SAP.DAL.Tables.Tournament { Id = viewModel.Id, Title = viewModel.Title, Description = viewModel.Description, StartDate = viewModel.StartDate.Add(viewModel.StartTime), EndDate = viewModel.EndDate.Add(viewModel.EndTime), MaxUsers = viewModel.MaxUsers }; bool result = _tournamentManager.EditTournament(tour); if (result) { TempData["Alert"] = SetAlert.Set("Poprawnie zmodfyfikowano turniej " + viewModel.Title, "Sukces", AlertType.Success); } else { TempData["Alert"] = SetAlert.Set("Wystąpił błąd, prosimy spróbować później", "Błąd", AlertType.Danger); } return(RedirectToAction("Index")); }
public ActionResult Contact(ContactModel model, string ReturnUrl) { var privateKey = ConfigurationManager.AppSettings.Get("reCaptchaPrivateKey"); if (ReCaptcha.Validate(privateKey)) { bool result = _contactManager.AddNewContact(model.Name, model.Surname, model.Email, model.Message); if (result) { TempData["Alert"] = SetAlert.Set("Dziękujemy za wiadomość!", "Sukces", AlertType.Success); return(RedirectToLocal(ReturnUrl)); } else { TempData["Alert"] = SetAlert.Set("Wystąpił błąd, prosimy spróbwać ponownie później.", "Błąd", AlertType.Danger); return(RedirectToAction("Contact")); } } else { TempData["Alert"] = SetAlert.Set("Musisz udowodnić że nie jesteś robotem poprzez captcha!", "Błąd", AlertType.Danger); return(View()); } }
public ActionResult UnBan(string name) { var userId = AspUserManager.FindByEmail(name).Id; AspUserManager.SetLockoutEndDate(userId, DateTimeOffset.MinValue); MvcHtmlString returnValue = Alert.GetAlert(SetAlert.Set("Poprawnie odblokowano " + name, "Sukces", AlertType.Success)); return(Json(new { Message = returnValue.ToHtmlString() })); }
public async Task <ActionResult> Register(RegisterViewModel model) { var privateKey = ConfigurationManager.AppSettings.Get("reCaptchaPrivateKey"); //sprawdzanie poprawności if (ReCaptcha.Validate(privateKey)) { if (ModelState.IsValid) { //rejestracja var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FirstName = model.Name, LastName = model.Surname, PhoneNumber = model.UserPhone, City = model.UserCity, HouseNumber = model.UserHouseNumber, PostalCode = model.UserPostalCode, Street = model.UserStreet }; var result = await UserManager.CreateAsync(user, model.Password); await UserManager.AddToRoleAsync(user.Id, "User"); UserManager.CreateSchool(user.Id, model.SchoolName, model.SchoolClass, model.SchoolCity, model.SchoolHouseNumber, model.SchoolPostalCode, model.CounselorFirstName, model.CounselorLastName, model.SchoolStreet, model.SchoolPhone); //operacje po rejestracji if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); TempData["Alert"] = SetAlert.Set("Dziękujemy za rejestrację w serwisie!", "Sukces", AlertType.Success); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Potwierdzenie rejestracji konta w SAP", "Potwierdź swój email klikająć <a href=\"" + callbackUrl + "\">tutaj</a>"); return(RedirectToLocal(callbackUrl)); } AddErrors(result); } } return(View(model)); }
public ActionResult Delete(int messageId) { bool result = _contactManager.Delete(messageId); if (result) { TempData["Alert"] = SetAlert.Set("Poprawnie usunięto wiadomość!", "Sukces", AlertType.Success); } else { TempData["Alert"] = SetAlert.Set("Wystąpił błąd", "Błąd", AlertType.Danger); } return(RedirectToAction("Index")); }
public ActionResult CourseSaveChanges(int tourId, int phaseId, int taskId) { bool result = _tournamentManager.CourseSaveChanges(tourId, phaseId, taskId); if (result) { var alert = SetAlert.Set("Poprawnie zmieniono przebieg turnieju o id " + tourId + "!", "Sukces", AlertType.Success); return(Json(Alert.GetAlert(alert).ToHtmlString())); } else { var alert = SetAlert.Set("Wystąpił błąd, spróbuj ponownie później", "Błąd", AlertType.Danger); return(Json(Alert.GetAlert(alert).ToHtmlString())); } }
public JsonResult DeleteTestData(int testId) { bool result = _tournamentManager.DeleteTestData(testId); if (result) { var alert = SetAlert.Set("Poprawnie usunięto dane testowe!", "Sukces", AlertType.Success); return(Json(Alert.GetAlert(alert).ToHtmlString())); } else { var alert = SetAlert.Set("Wystąpił błąd, spróbuj ponownie później", "Błąd", AlertType.Danger); return(Json(Alert.GetAlert(alert).ToHtmlString())); } }
public ActionResult TodaySystemTask() { //var todayTask = TodoManager.todayTasks; //List<TodaySystemTaskViewModel> viewModel = new List<TodaySystemTaskViewModel>(); //todayTask.ForEach(x => //{ // TodaySystemTaskViewModel task = new TodaySystemTaskViewModel(); // switch (x.TaskType) // { // case TaskType.ScoreCount: // task.TournamentId = x.TournamentId; // task.PhaseId = x.PhaseId; // task.TypeOfTask = "Podsumowanie wyników"; // break; // case TaskType.SetPromotions: // task.TournamentId = x.TournamentId; // task.PhaseId = x.PhaseId; // task.TypeOfTask = "Przydzielenie awansów"; // break; // default: // task.TaskId = x.TaskId; // task.TypeOfTask = x.TaskType == TaskType.StartPhase ? "Start fazy" // : x.TaskType == TaskType.EndPhase ? "Koniec fazy" // : x.TaskType == TaskType.StartTask ? "Start zadania" // : x.TaskType == TaskType.EndTask ? "Koniec zadania" // : x.TaskType == TaskType.StartTournament ? "Początek turnieju" // : x.TaskType == TaskType.EndTournament ? "Koniec turnieju" // : String.Empty; // break; // } // task.ExecuteTime = x.ExecuteTime; // task.IsRealized = x.IsRealized; // task.TaskType = x.TaskType; // viewModel.Add(task); //}); //ViewBag.LastSynchro = TodoManager.LastSynchronized; //return View(viewModel); TempData["Alert"] = SetAlert.Set("Opcja w tej wersji jest niedostępna.", "Uwaga", AlertType.Warning); return(RedirectToAction("Index")); }
public JsonResult EditNews(int id, string desc) { bool result = _newsManager.EditNews(id, desc); MvcHtmlString jsonResult; if (result) { jsonResult = Alert.GetAlert(SetAlert.Set("Poprawnie zaktualizowano news!", "Sukcess", AlertType.Success)); } else { jsonResult = Alert.GetAlert(SetAlert.Set("Wystąpił błąd, spróbuj ponownie później!", "Błąd", AlertType.Danger)); } return(Json(jsonResult.ToHtmlString())); }
// // GET: /Manage/Index public ActionResult Index(ManageMessageId?message) { ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? SetAlert.Set("Twoje hasło zostało zmienione.", "Sukces", AlertType.Success) : message == ManageMessageId.ChangeSchoolDataSuccess ? SetAlert.Set("Dane szkoły zostały zaktualizowane.", "Sukces", AlertType.Success) : message == ManageMessageId.ChangeCounselorDataSuccess ? SetAlert.Set("Dane opiekuna zostały zaktualizowane.", "Sukces", AlertType.Success) : message == ManageMessageId.ChangeUserDataSuccess ? SetAlert.Set("Twoje dane zostały zaktualizowane.", "Sukces", AlertType.Success) : message == ManageMessageId.ChangeEmailSuccess ? SetAlert.Set("Twój email został zmieniony. Na twoją skrzynkę pocztową zostało wysłane nowe potwierdzenie adresu.", "Sukces", AlertType.Success) : message == ManageMessageId.Error ? SetAlert.Set("Wystąpił nieoczekiwany błąd. Spróbuj ponownie później.", "Błąd", AlertType.Danger) : null; ViewBag.Email = AspUserManager.IsEmailConfirmed(User.Identity.GetUserId()); ViewBag.Phone = AspUserManager.IsPhoneNumberConfirmed(User.Identity.GetUserId()); return(View()); }
public JsonResult AddNews(string title, string description) { bool result = _newsManager.AddNews(title, description); MvcHtmlString jsonResult; if (result) { jsonResult = Alert.GetAlert(SetAlert.Set("Poprawnie dodano news!", "Sukcess", AlertType.Success)); } else { jsonResult = Alert.GetAlert(SetAlert.Set("Wystąpił błąd, spróbuj ponownie później!", "Błąd", AlertType.Danger)); } return(Json(jsonResult.ToHtmlString())); }
public JsonResult DeleteNews(int id) { bool result = _newsManager.DeleteNews(id); MvcHtmlString jsonResult; if (result) { jsonResult = Alert.GetAlert(SetAlert.Set("Poprawnie usunięto news!", "Sukcess", AlertType.Success)); } else { jsonResult = Alert.GetAlert(SetAlert.Set("Wystąpił błąd, spróbuj ponownie później!", "Błąd", AlertType.Danger)); } return(Json(jsonResult.ToHtmlString())); }
public JsonResult Delete(int messageId) { bool result = _userManager.DeleteMessage(messageId); MvcHtmlString alert; if (result) { alert = Alert.GetAlert(SetAlert.Set("Poprawnie usunięto wiadomość!", "Sukces", AlertType.Success)); } else { alert = Alert.GetAlert(SetAlert.Set("Wystąpił błąd!", "Błąd", AlertType.Danger)); } return(Json(alert.ToHtmlString())); }
public async Task <ActionResult> AddTestDataTask(List <TestDataViewModel> viewModel) { if (ModelState.IsValid) { List <TasksTestData> listData = new List <TasksTestData>(); foreach (var item in viewModel) { listData.Add(new TasksTestData { InputData = item.InputData, OutputData = item.OutputData, TaskId = item.TaskId }); } bool result = await _tournamentManager.AddTestDataAsync(listData); if (result) { TempData["Alert"] = SetAlert.Set("Poprawnie wprowadzono dane testowe!", "Sukces", AlertType.Success); return(RedirectToAction("AddTestDataTask")); } else { TempData["Alert"] = SetAlert.Set("Wystąpił błąd. Spróbuj ponownie później", "Błąd", AlertType.Danger); return(RedirectToAction("AddTestDataTask")); } } else { var tournamnets = _tournamentManager.Tournaments .Select(x => x) .Where(x => x.IsConfigured == false); //zwraca nieskonfigurowane turnieje List <SelectListItem> tourList = new List <SelectListItem>(); foreach (var item in tournamnets) { tourList.Add(new SelectListItem { Value = item.Id.ToString(), Text = item.Title }); } TempData["Alert"] = SetAlert.Set("Sprawdź poprawnośc danych!", "Błąd", AlertType.Danger); return(View(viewModel)); } }
public ActionResult AddAdministrator(AddAdminViewModel viewModel) { ApplicationUser user = new ApplicationUser { FirstName = viewModel.FirstName, LastName = viewModel.LastName, UserName = viewModel.Email, Email = viewModel.Email, EmailConfirmed = true }; AspUserManager.Create(user, viewModel.Password); AspUserManager.AddToRole(user.Id, "Admin"); TempData["Alert"] = SetAlert.Set("Konto poprawnie stworzone!", "Sukces", AlertType.Success); return(RedirectToAction("ManageAccounts")); }
public ActionResult ChangePath(int systemId, string path, string arguments) { bool resultPath = _compilerManager.EditPath(systemId, path); bool resultArg = _compilerManager.EditArguments(systemId, arguments); if (resultPath && resultArg) { TempData["Alert"] = SetAlert.Set("Poprawnie zmieniono scieżkę!", "Sukces", AlertType.Success); } else { TempData["Alert"] = SetAlert.Set("Wystąpił błąd!", "Błąd", AlertType.Danger); } ServerConfig.CompilersSetup(); return(RedirectToAction("Index")); }
public ActionResult SendMessageToUser(string name, string title, string desc) { var user = AspUserManager.FindByName(name); bool result = _userManager.SendMessage(user.Id, title, desc); MvcHtmlString jsonData = null; if (result) { jsonData = Alert.GetAlert(SetAlert.Set("Poprawnie wysłano wiadomość do " + name, "Sukces", AlertType.Success)); } else { jsonData = Alert.GetAlert(SetAlert.Set("Wystąpił bład. Spróbuj ponownie później.", "Błąd", AlertType.Danger)); } return(Json(new { Message = jsonData.ToHtmlString() })); }
// GET: Admin/Home public async Task <ActionResult> Index(Message?message) { ViewBag.Message = message == Message.ChangeDataSuccess ? SetAlert.Set("Dane zostały poprawnie zmienione!", "Sukces", AlertType.Success) : message == Message.ChagnePasswordSuccess ? SetAlert.Set("Hasło zostało poprawnie zmienione!", "Sukces", AlertType.Success) : message == Message.Error ? SetAlert.Set("Wystąpił błąd, spróbuj ponownie poźniej", "Uwaga", AlertType.Danger) : null; var adminData = await AspUserManager.FindByNameAsync(User.Identity.Name); AdminDataViewModel viewModel = new AdminDataViewModel { FirstName = adminData.FirstName, LastName = adminData.LastName, Email = adminData.Email, Role = HttpContext.User.IsInRole("Root") ? "Root (super admin)" : "Administrator" }; return(View(viewModel)); }
public ActionResult Ban(string name, string banTime, string banDate, bool isPernament) { MvcHtmlString alert = null; if (isPernament) { var user = AspUserManager.FindByEmail(name); AspUserManager.SetLockoutEndDate(user.Id, DateTimeOffset.MaxValue); alert = Alert.GetAlert(SetAlert.Set("Pernamentnie zbanowano " + name, "Sukces", AlertType.Success)); } else { DateTime endDate; string dateAndTime = banDate + " " + banTime; bool parseResult = DateTime.TryParse(dateAndTime, out endDate); if (parseResult) { if (endDate >= DateTime.Now) { var user = AspUserManager.FindByEmail(name); AspUserManager.SetLockoutEndDate(user.Id, endDate); alert = Alert.GetAlert(SetAlert.Set("Poprawnie zablokowano " + name, "Sukces", AlertType.Success)); } else { alert = Alert.GetAlert(SetAlert.Set("Musisz podać datę większą od dnia dzisiejszego", "Błąd", AlertType.Danger)); } } else { alert = Alert.GetAlert(SetAlert.Set("Data lub godzina została podana błędnie. Schemat: dd-mm-rrrr hh:ss", "Błąd", AlertType.Danger)); } } return(Json(new { Message = alert.ToHtmlString() })); }
public ActionResult EditTask(ManageTaskViewModel model) { var dbModel = new Tasks { Title = model.Title, Description = model.Description, StartDate = model.StartDate.Add(model.StartTime), EndDate = model.EndDate.Add(model.EndTime), Example = model.Example, Input = model.Input, Id = model.TaskId, InputDataTypeId = model.InputDataId, Output = model.Output, MaxExecuteMemory = model.MaxExecutedMemory, MaxExecuteTime = model.MaxExecutedTime }; if (model.PDF != null) { byte[] newPDF = new byte[model.PDF.ContentLength]; model.PDF.InputStream.Read(newPDF, 0, model.PDF.ContentLength); dbModel.PDF = newPDF; } bool result = _tournamentManager.EditTask(dbModel); if (result) { TempData["Alert"] = SetAlert.Set("Poprawnie edytowano: " + dbModel.Title, "Sukces", AlertType.Success); } else { TempData["Alert"] = SetAlert.Set("Wystąpił błąd. Spróbuj ponownie później!", "Błąd", AlertType.Danger); } return(RedirectToAction("Index")); }
public async Task <ActionResult> ChangePassword(ChangePasswordViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var result = await AspUserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword); if (result.Succeeded) { var user = await AspUserManager.FindByNameAsync(User.Identity.GetUserId()); if (user != null) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); } return(RedirectToAction("Index", new { Message = Message.ChagnePasswordSuccess })); } else { TempData["Alert"] = SetAlert.Set("Wprowadzone hasło jest niepoprawne!", "Błąd", AlertType.Danger); return(View(model)); } }
public async Task <ActionResult> AddTournament(AddTournamentViewModel viewModel) { if (ModelState.IsValid) { int[] taskCountPerPhase = new int[viewModel.Phases.Count]; for (int i = 0; i < taskCountPerPhase.Length; i++) { taskCountPerPhase[i] = viewModel.TaskContainer[i].Tasks.Count; } DAL.Tables.Tournament tour = new DAL.Tables.Tournament { Title = viewModel.Tournament.Title, Description = viewModel.Tournament.Description, StartDate = viewModel.Tournament.StartDate.Add(viewModel.Tournament.StartTime), EndDate = viewModel.Tournament.EndDate.Add(viewModel.Tournament.EndTime), MaxUsers = viewModel.Tournament.MaxUsers }; List <Phase> phases = new List <Phase>(); viewModel.Phases.ForEach(x => { phases.Add(new Phase { MaxUsers = x.MaxUsers, Name = x.Name, Order = x.Order, MaxTasks = x.TaskCount }); }); List <Tasks> tasks = new List <Tasks>(); viewModel.TaskContainer.ForEach(x => { x.Tasks.ForEach(y => { var task = new Tasks { Title = y.Title, Order = y.Order, Description = y.Description, EndDate = y.EndDate.Add(y.EndTime), StartDate = y.StartDate.Add(y.StartTime), Input = y.Input, Output = y.Output, Example = y.Example, MaxExecuteMemory = y.MaxExecutedMemory, MaxExecuteTime = y.MaxExecutedTime, InputDataTypeId = y.InputDataId }; if (y.PDF != null) { byte[] pdf = new byte[y.PDF.ContentLength]; y.PDF.InputStream.Read(pdf, 0, y.PDF.ContentLength); task.PDF = pdf; } tasks.Add(task); }); }); bool result = await _tournamentManager.AddTournamnetAsync(tour, phases, tasks, taskCountPerPhase); if (result) { TempData["Alert"] = SetAlert.Set("Poprawnie dodano turniej! Teraz skonfiguruj dane testowe do poszczególnych zadań, by móc poprawnie aktywować turniej.", "Sukces", AlertType.Info); return(RedirectToAction("Index")); } else { TempData["Alert"] = SetAlert.Set("Wystąpił błąd z bazą danych. Spróbuj ponownie później.", "Błąd", AlertType.Danger); return(View(viewModel)); } } else { TempData["Alert"] = SetAlert.Set("Wystąpił błąd, proszę sprawdź wszystkie kroki.", "Błąd!", AlertType.Danger); return(View(viewModel)); } }
public ActionResult ChangeEmail() { TempData["Alert"] = SetAlert.Set("Zmieniając email będziesz musiał logować się przy pomocy nowego adresu.", "Uwaga", AlertType.Warning); return(View()); }