public async Task <IActionResult> Edit(int id) { bool postExists = await this.postsService.CheckIfPostExistsAsync(id); if (!postExists) { return(this.ProcessNullEntity(nameof(Post))); } bool canEditPost = await this.postsService.CheckIfIsAllowedToPerformAsync(this.User.Identity.Name, id); if (!canEditPost) { var messageModel = new MessageModel() { Type = MessageType.Warning, Message = Messages.NotAllowedMsg }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, messageModel); return(this.RedirectToAction("Index")); } var model = await this.postsService.GetPostForEditAsync(id); return(this.View(model)); }
public async Task <IActionResult> Details(string id) { bool userExists = await this.usersService.CheckIfUserExistsAsync(id); if (!userExists) { return(this.ProcessNullEntity(nameof(Blog.Models.User))); } var currentUserId = await this.userProfileService.GetUserIdAsync(this.User.Identity.Name); if (id == currentUserId) { var messageModel = new MessageModel() { Type = MessageType.Warning, Message = Messages.NotAllowedMsg }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, messageModel); return(this.RedirectToAction("Index", "Users", new { Area = "Admin" })); } var model = await this.usersService.GetUserDetailsAsync(id); return(this.View(model)); }
public async Task <IActionResult> Edit(PostEditBindingModel model) { bool canEditPost = await this.postsService.CheckIfIsAllowedToPerformAsync(this.User.Identity.Name, model.Id); if (!canEditPost) { var messageModel = new MessageModel() { Type = MessageType.Warning, Message = Messages.NotAllowedMsg }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, messageModel); return(this.RedirectToAction("Index")); } if (!this.ModelState.IsValid) { model.Categories = await this.postsService.GenerateCategoriesSelectListAsync(); return(this.View(model)); } model = TSelfExtensions.TrimStringProperties(model); int id = await this.postsService.EditPostAsync(model); var message = new MessageModel() { Type = MessageType.Success, Message = string.Format(Messages.EntityEditSuccess, nameof(Post), id) }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, message); return(this.RedirectToAction("Details", new { id = id })); }
public async Task <IActionResult> Park(ParkParkedVehicleViewModel viewModel) { var parkSpots = ParkingSpotContainer.GetParkSpots(_configuration); if (ModelState.IsValid) { var vehicle = new ParkedVehicle(); vehicle.VehicleTypeId = int.Parse(Request.Form["Type"].ToString()); if (vehicle.VehicleTypeId == 0) { throw new ArgumentException("The value of the SelectItem selected was zero."); } var member = TempDataExtensions.Get <Member>(TempData, "member"); vehicle.MemberId = member.MemberId; PopulateVehicleFromViewModel(viewModel, vehicle); await ParkVehicleInBackend(parkSpots, vehicle); vehicle.IsParked = true; _context.Add(vehicle); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View()); }
public async Task <IActionResult> Destroy(int id) { bool replyExists = await this.repliesService.CheckIfReplyExistsAsync(id); if (!replyExists) { return(this.ProcessNullEntity(nameof(Reply))); } bool succeeded = await this.repliesService.DeleteReplyAsync(id); if (succeeded) { var message = new MessageModel() { Type = MessageType.Success, Message = string.Format(Messages.EntityDeleteSuccess, nameof(Reply), id) }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, message); return(this.RedirectToAction("Index", "Replies", new { Area = "Admin" })); } else { var message = new MessageModel() { Type = MessageType.Warning, Message = $"Unexpected error occurred deleting reply with ID: {id}." }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, message); return(this.RedirectToAction("Delete", "Replies", new { id = id, Area = "Admin" })); } }
public async Task <IActionResult> UnParkConfirmed(string RegNum) { var vehicle = await _context.ParkedVehicles.FindAsync(RegNum); var vehicleType = await _context.VehicleTypes.FirstOrDefaultAsync(t => t.Id == vehicle.VehicleTypeId); var spotsRequired = GetRequiredNumberOfSpots(vehicleType); if (vehicle != null) { vehicle.IsParked = false; _context.Update(vehicle); await _context.SaveChangesAsync(); } else { throw new ArgumentNullException(nameof(vehicle), "The vehicle could not be found in the database."); } ParkSpot spot; // TODO: More elegant solution without extra calls to FindSpotByVehicle for (var i = 0; i < spotsRequired; i++) { spot = ParkingSpotContainer.FindSpotByVehicle(vehicle); spot.Unpark(vehicle); } TempDataExtensions.Set(TempData, "vehicle", vehicle); TempData.Keep(); return(RedirectToAction(nameof(ParkingReceipt))); }
public async Task <IActionResult> Approve(int id) { bool commentExists = await this.commentsService.CheckIfCommentExistsAsync(id); if (!commentExists) { return(this.ProcessNullEntity(nameof(Comment))); } bool succeeded = await this.commentsService.ApproveCommentAsync(id); if (succeeded) { var message = new MessageModel() { Type = MessageType.Success, Message = string.Format(Messages.EntityApproveSuccess, nameof(Comment), id) }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, message); } else { var message = new MessageModel() { Type = MessageType.Warning, Message = $"Unexpected error occurred approving comment with ID: {id}." }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, message); } return(this.RedirectToAction("Index", "Comments", new { Area = "Admin" })); }
public async Task <IActionResult> OnPostAsync(List <IFormFile> files) { this.ExternalLogins = (await this.signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (!this.ModelState.IsValid) { // If we got this far, something failed, redisplay form return(this.Page()); } var user = new ApplicationUser { UserName = this.Input.Email, Email = this.Input.Email, CreatedOn = DateTime.UtcNow, Description = this.Input.Description, FirstName = this.Input.FirstName, LastName = this.Input.LastName, CountryCode = this.Input.CountryCode, }; var result = await this.userManager.CreateAsync(user, this.Input.Password); if (this.Input.Image != null) { await this.usersService.AddUserImageAsync(this.Input.Image, user.UserName); } var code = await this.userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = this.Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { userId = user.Id, code = code }, protocol: this.Request.Scheme); await this.emailService.SendEmailToUserAsync(callbackUrl, this.Input.Email); if (result.Succeeded) { this.logger.LogInformation(SuccessfullyCreatedUserLog); this.TempData.Clear(); TempDataExtensions.Put <EmailViewModel>(this.TempData, "EmailOptions", new EmailViewModel { Email = this.Input.Email, CallbackUrl = callbackUrl }); return(this.RedirectToPage("VerifyEmail")); } foreach (var error in result.Errors) { this.ModelState.AddModelError(string.Empty, error.Description); } return(this.Page()); }
public static void Enviar(this ITempDataDictionary tempData, string titulo, string tipo, string texto) { MensajesViewModel mensaje = new MensajesViewModel(); mensaje.Titulo = titulo; mensaje.Texto = texto; mensaje.Tipo = tipo; TempDataExtensions.Put <MensajesViewModel>(tempData, "mensaje", mensaje); }
public async Task <IActionResult> OnPost() { bool postExists = await this.postsService.CheckIfPostExistsAsync(this.PostId, this.Slug); if (!postExists) { return(this.NotFound()); } if (this.Message == null) { var msgModel = new MessageModel() { Type = MessageType.Warning, Message = Messages.FillFormMsg }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, msgModel); return(this.Redirect($"/{Constants.Business}/{this.PostId}/{this.Slug}")); } var user = await this.userManager.GetUserAsync(this.User); if (user.IsBanned) { var msgModel = new MessageModel() { Type = MessageType.Warning, Message = Messages.NotAllowedToComment }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, msgModel); return(this.Redirect($"/{Constants.Business}/{this.PostId}/{this.Slug}")); } string userId = await this.userService.GetUserIdAsync(this.User.Identity.Name); bool commentExists = await this.commentsService.CheckIfCommentExistsAsync(this.CommentId); if (commentExists) { await this.repliesService.CreateReplyAsync(userId, this.CommentId, this.Message); } else { await this.commentsService.CreateCommentAsync(userId, this.PostId, this.Message); } var message = new MessageModel() { Type = MessageType.Success, Message = Messages.CommentSuccess }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, message); return(this.Redirect($"/{Constants.Business}/{this.PostId}/{this.Slug}")); }
public async Task <IActionResult> ChangePassword(UserChangePasswordBindingModel model) { bool userExists = await this.usersService.CheckIfUserExistsAsync(model.Id); if (!userExists) { return(this.ProcessNullEntity(nameof(Blog.Models.User))); } var currentUserId = await this.userProfileService.GetUserIdAsync(this.User.Identity.Name); if (model.Id == currentUserId) { var messageModel = new MessageModel() { Type = MessageType.Warning, Message = Messages.NotAllowedMsg }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, messageModel); return(this.RedirectToAction("Index", "Users", new { Area = "Admin" })); } if (!this.ModelState.IsValid) { var viewModel = new UserChangePasswordBindingModel() { Id = model.Id, Username = model.Username }; return(this.View(viewModel)); } model = TSelfExtensions.TrimStringProperties(model); bool succeeded = await this.usersService.ChangePasswordAsync(model); if (succeeded) { var message = new MessageModel() { Type = MessageType.Success, Message = $"The password of user with Username: {model.Username} has been changed successfully." }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, message); } else { var message = new MessageModel() { Type = MessageType.Warning, Message = $"Unexpected error occurred changing password of User with Username: {model.Username}." }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, message); } return(this.RedirectToAction("Details", "Users", new { id = model.Id, Area = "Admin" })); }
protected virtual IActionResult ProcessNullEntity(string entityName) { var messageModel = new MessageModel() { Type = MessageType.Danger, Message = string.Format(Messages.EntityDoesNotExist, entityName) }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, messageModel); return(this.RedirectToAction("Index")); }
public IActionResult CheckEmail(EmailAddress emailAddress) { var result = _context.Members.FirstOrDefault(m => m.Email == emailAddress.Email); if (result != null) { TempDataExtensions.Set(TempData, "member", result); TempData.Keep(); return(RedirectToAction(nameof(VehiclesController.Park), "Vehicles")); } return(RedirectToAction(nameof(RegistrationRequired))); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = this.Url.Content("/Identity/Account/Login"); if (this.ModelState.IsValid) { this.Input = TSelfExtensions.TrimStringProperties(this.Input); var user = new User { UserName = this.Input.Username, Email = this.Input.Email, AvatarUrl = Constants.DefaultAvatarPath }; var result = await this.userManager.CreateAsync(user, this.Input.Password); if (result.Succeeded) { this.logger.LogInformation("User created a new account with password."); var code = await this.userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = this.Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { userId = user.Id, code = code }, protocol: this.Request.Scheme); await this.emailSender.SendEmailAsync( this.Input.Email, "Confirm your email", $"Please confirm your Blogger account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); var messageModel = new MessageModel() { Type = MessageType.Success, Message = "You have registered successfully. Please log in." }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, messageModel); return(this.LocalRedirect(returnUrl)); } foreach (var error in result.Errors) { this.ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(this.Page()); }
public ActionResult SaveVol(Vol Vol) { var validator = new VolValidator(); var validatorResult = validator.Validate(Vol); if (validatorResult.IsValid) { var SavedFlights = HttpContext.Session.GetObjectFromJson <List <Vol> >("SavedVols"); if (SavedFlights != null) { IDVol = IDVol + 1; Vol.IdVol = IDVol; SavedFlights.Add(Vol); HttpContext.Session.SetObjectAsJson("SavedVols", SavedFlights); return(RedirectToRoute(new { controller = "Home", action = "ListVols" })); } else { List <Vol> vols = new List <Vol>(); Vol.IdVol = IDVol; vols.Add(Vol); HttpContext.Session.SetObjectAsJson("SavedVols", vols); return(RedirectToRoute(new { controller = "Home", action = "ListVols", })); } } else { Vol.Errors = new List <string>(); foreach (var item in validatorResult.Errors) { Vol.Errors.Add(item.ErrorMessage); } TempDataExtensions.Put(TempData, "VolObject", Vol); return(RedirectToRoute(new { controller = "Home", action = "Index", })); } }
public IActionResult Maintenance() { var response = TempDataExtensions.Get <KitsuneStatusResponse>(TempData, "kitsuneStatus"); if (response == null) { response = Helpers.KitsuneApiStatusCheck(TempData); if (response.Success && !response.IsDown) { return(RedirectToAction("Index", "Home")); } } ViewBag.kitsuneStatus = response; return(View("Maintenance")); }
public async Task <IActionResult> MakeAuthor(string id) { bool userExists = await this.usersService.CheckIfUserExistsAsync(id); if (!userExists) { return(this.ProcessNullEntity(nameof(Blog.Models.User))); } var currentUserId = await this.userProfileService.GetUserIdAsync(this.User.Identity.Name); if (id == currentUserId) { var messageModel = new MessageModel() { Type = MessageType.Warning, Message = Messages.NotAllowedMsg }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, messageModel); return(this.RedirectToAction("Index", "Users", new { Area = "Admin" })); } bool succeeded = await this.usersService.MakeAuthorAsync(id); var username = await this.usersService.GetUsernameByUserIdAsync(id); if (succeeded) { var message = new MessageModel() { Type = MessageType.Success, Message = $"The user with Username: {username} was assigned with role \"{Constants.Author}\" successfully." }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, message); } else { var message = new MessageModel() { Type = MessageType.Warning, Message = $"Unexpected error occurred assigning role \"{Constants.Author}\" to User with Username: {username}." }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, message); } return(this.RedirectToAction("Details", "Users", new { id = id, Area = "Admin" })); }
public IActionResult ParkingReceipt() { var vehicle = TempDataExtensions.Get <ParkedVehicle>(TempData, "vehicle"); if (vehicle == null) { throw new Exception("JsonConvert failed to convert TempData"); } DateTime currentTime; TimeSpan parkingDuration; decimal cost; GetParkingCost(vehicle, out currentTime, out parkingDuration, out cost); var member = _context.Members.FirstOrDefault(m => m.MemberId == vehicle.MemberId); var memberFullName = member.FullName; var model = new Tuple <ParkedVehicle, DateTime, TimeSpan, decimal, string>(vehicle, currentTime, parkingDuration, cost, memberFullName); return(View(model)); }
public async Task <IActionResult> Create(PostCreateBindingModel model) { if (!this.ModelState.IsValid) { model.Categories = await this.postsService.GenerateCategoriesSelectListAsync(); return(this.View(model)); } model = TSelfExtensions.TrimStringProperties(model); int id = await this.postsService.CreatePostAsync(model, this.User.Identity.Name); var messageModel = new MessageModel() { Type = MessageType.Success, Message = string.Format(Messages.EntityCreateSuccess, nameof(Post), id) }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, messageModel); return(this.RedirectToAction("Details", new { id = id })); }
public async Task <IActionResult> Edit(CategoryEditBindingModel model) { bool categoryExists = await this.categoriesService.CheckIfCategoryExistsAsync(model.Id); if (!categoryExists) { return(this.ProcessNullEntity(nameof(Category))); } if (!this.ModelState.IsValid) { return(this.View(model)); } model = TSelfExtensions.TrimStringProperties(model); var categoryNameWithSameOrder = await this.categoriesService .CategoryWithSameOrderAsync(model.Id, model.Order); if (categoryNameWithSameOrder != null) { this.ModelState.AddModelError( nameof(model.Order), $"{nameof(Category)} \"{categoryNameWithSameOrder}\" already has order \"{model.Order}\"."); return(this.View(model)); } int id = await this.categoriesService.EditCategoryAsync(model); var messageModel = new MessageModel() { Type = MessageType.Success, Message = string.Format(Messages.EntityEditSuccess, nameof(Category), id) }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, messageModel); return(this.RedirectToAction("Details", "Categories", new { id = id, Area = "Admin" })); }
public async Task <IActionResult> OnGet(string returnUrl = null) { if (!string.IsNullOrEmpty(this.ErrorMessage)) { this.ModelState.AddModelError(string.Empty, this.ErrorMessage); } if (this.User.Identity.IsAuthenticated) { this.TempData["alert"] = ConfirmEmailMsg; return(this.Redirect("~/Home/Index")); } returnUrl = returnUrl ?? this.Url.Content("~/"); TempDataExtensions.Put <EmailViewModel>(this.TempData, "EmailOptions", new EmailViewModel { Email = this.EmailViewModel.Email, CallbackUrl = this.EmailViewModel.CallbackUrl }); this.ReturnUrl = returnUrl; return(this.Page()); }
public async Task <IActionResult> PerformSearch(string searchTerm) { if (string.IsNullOrWhiteSpace(searchTerm)) { var message = new MessageModel() { Type = MessageType.Warning, Message = "Please enter a text to search." }; TempDataExtensions.Put(this.TempData, Constants.TempDataKey, message); return(this.RedirectToAction("Search")); } var posts = await this.postsService.GetPostsBySearchTermAsync(searchTerm); var model = new SearchResultViewModel() { Posts = posts, SearchTerm = searchTerm }; return(this.PartialView("_SearchResult", model)); }
public async Task <IActionResult> OnPostAsync() { if (!this.ModelState.IsValid) { string cloudinaryUrl = await this.usersService.GetUserImageIfExistsAsync(this.User.Identity.Name); this.Input.ImageCloudUrl = cloudinaryUrl; return(this.Page()); } var user = await this.userManager.GetUserAsync(this.User); if (user == null) { return(this.NotFound(value: $"Unable to load user with ID '{this.userManager.GetUserId(this.User)}'.")); } var email = await this.userManager.GetEmailAsync(user); if (this.Input.Email != email) { var userExists = await this.userManager.FindByEmailAsync(this.Input.Email); if (userExists != null) { this.TempData.Clear(); this.TempData["alert"] = ExistsEmailErrorMsg; } else { var callbackUrl = this.Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { userId = user.Id }, protocol: this.Request.Scheme); await this.emailService.SendEmailToUserAsync(callbackUrl, this.Input.Email); this.TempData.Clear(); TempDataExtensions.Put <EmailViewModel>(this.TempData, Key, new EmailViewModel { Email = this.Input.Email, CallbackUrl = callbackUrl }); string distributedCacheKey = email; await this.distributedCache.SetStringAsync(user.Email, this.Input.Email); this.TempData["alert"] = UpdateEmailErrorMsg; } } user.CountryCode = this.Input.Country; user.ModifiedOn = DateTime.UtcNow; user.Profession = this.Input.Profession; user.FirstName = this.Input.FirstName; user.LastName = this.Input.LastName; user.Description = this.Input.Description; if (this.Input.Image != null) { if (user.ImageId != null) { await this.usersService.DeleteUserImgAsync(user.UserName); } await this.usersService.AddUserImageAsync(this.Input.Image, user.UserName); } this.efRepository.Update(user); await this.efRepository.SaveChangesAsync(); await this.signInManager.RefreshSignInAsync(user); this.StatusMessage = ProfileUpdateMsg; return(this.RedirectToPage()); }
protected IActionResult RedirectToActionError(string action, string message) { TempDataExtensions.SetRedirectMessage(TempData, message); TempDataExtensions.SetRedirectStatus(TempData, RedirectStatus.Error); return(RedirectToAction(action)); }
protected IActionResult RedirectToActionError(string action, string controller, object routeValues, string message) { TempDataExtensions.SetRedirectMessage(TempData, message); TempDataExtensions.SetRedirectStatus(TempData, RedirectStatus.Error); return(RedirectToAction(action, controller, routeValues)); }
protected IActionResult ViewOk(string viewName, object routeValues, string message) { TempDataExtensions.SetRedirectMessage(TempData, message); TempDataExtensions.SetRedirectStatus(TempData, RedirectStatus.Success); return(View(viewName, routeValues)); }
// TODO: VOLVERLO UN PAQUETE PARA REUTILIZARLO /// <summary> /// Enviar mensaje a la vista. /// TIPO: color del mensaje | /// FUNC: la operación que se ejecuta /// (0=ID no encontrado, 1=guardar, 2=generar, 3=actualizar, 4=cambiar estado, 5=eliminar, 6=secuencia existente, 7=archivo inválido, 8=archivo muy grande, 9 = No ha seleccionado productos, /// 10 = No se pudo cambiar el estatus, 11 = campo vacío) /// </summary> /// <param name="tipo"></param> /// <param name="func"></param> ///<returns>mensaje</returns> public static void Enviar(this ITempDataDictionary tempData, string tipo, int func) { MensajesViewModel mensaje = new MensajesViewModel("", "", ""); tempData.Clear(); if (func == 1) { if (tipo == "red") { mensaje.Titulo = "Hubo un error"; mensaje.Texto = "No se pudo guardar la información"; mensaje.Tipo = tipo; } if (tipo == "green") { mensaje.Titulo = "Información guardada"; mensaje.Texto = "La información se pudo guardar satisfactoriamente"; mensaje.Tipo = tipo; } } else if (func == 2) { if (tipo == "red") { mensaje.Titulo = "Hubo un error"; mensaje.Texto = "No se pudo generar la información"; mensaje.Tipo = tipo; } if (tipo == "green") { mensaje.Titulo = "Información generada"; mensaje.Texto = "La información se pudo generar satisfactoriamente"; mensaje.Tipo = tipo; } } else if (func == 3) { if (tipo == "red") { mensaje.Titulo = "Hubo un error"; mensaje.Texto = "No se pudo actualizar la información"; mensaje.Tipo = tipo; } if (tipo == "green") { mensaje.Titulo = "Actualización completa"; mensaje.Texto = "La información se pudo actualizar satisfactoriamente"; mensaje.Tipo = tipo; } } else if (func == 4) { if (tipo == "red") { mensaje.Titulo = "Hubo un error"; mensaje.Texto = "No se pudo cambiar el estado"; mensaje.Tipo = tipo; } if (tipo == "green") { mensaje.Titulo = "Actualización del estado"; mensaje.Texto = "El estado se pudo actualizar satisfactoriamente"; mensaje.Tipo = tipo; } } else if (func == 5) { if (tipo == "red") { mensaje.Titulo = "Hubo un error"; mensaje.Texto = "No se pudo eliminar la información"; mensaje.Tipo = tipo; } if (tipo == "green") { mensaje.Titulo = "Información eliminada"; mensaje.Texto = "La información fue eliminada permanentemente!"; mensaje.Tipo = tipo; } } else if (func == 6) { if (tipo == "red") { mensaje.Titulo = "Comprobantes existentes"; mensaje.Texto = "Ya existen comprobantes con esa secuencia"; mensaje.Tipo = tipo; } if (tipo == "green") { mensaje.Titulo = "Información eliminada"; mensaje.Texto = "La información fue eliminada permanentemente!"; mensaje.Tipo = tipo; } } // Archivo inválido else if (func == 7) { if (tipo == "red") { mensaje.Titulo = "Archivo Inválido"; mensaje.Texto = "verifique si cargó un archivo o si este es de la extensión requerida (ej: si es imagen:.jpg, excel: .xls ó documento:s .pdf)"; mensaje.Tipo = tipo; } if (tipo == "green") { mensaje.Titulo = "Archivo cargado correctamente"; mensaje.Texto = "El archivo se guardó en el servidor satisfactoriamente"; mensaje.Tipo = tipo; } } // Archivo muy grande else if (func == 8) { if (tipo == "red") { mensaje.Titulo = "Archivo muy grande"; mensaje.Texto = "Debe cargar in documento que tenga un tamaño permitido (3 MB o menos)"; mensaje.Tipo = tipo; } if (tipo == "green") { mensaje.Titulo = "Archivo cargado correctamente"; mensaje.Texto = "El archivo se guardó en el servidor satisfactoriamente"; mensaje.Tipo = tipo; } } // Seleccionar producto else if (func == 9) { if (tipo == "red") { mensaje.Titulo = "Piezas sin seleccionar"; mensaje.Texto = "Debe seleccionar una pieza por lo menos"; mensaje.Tipo = tipo; } } // Cambiar estatus else if (func == 10) { if (tipo == "red") { mensaje.Titulo = "No se pudo cambiar el estado"; mensaje.Texto = "Hubo un error al intentar cambiar el estado, intentelo luego, o contacte al administrador del sistema"; mensaje.Tipo = tipo; } } // Cambiar estatus else if (func == 11) { if (tipo == "red") { mensaje.Titulo = "Campo vacío"; mensaje.Texto = "verifique que esté completando todos los campos de texto"; mensaje.Tipo = tipo; } } else if (func == 12) { if (tipo == "red") { mensaje.Titulo = "Contraseña Incorrecta"; mensaje.Texto = "Asegúrese de completar todos los campos"; mensaje.Tipo = tipo; } if (tipo == "green") { mensaje.Titulo = "Contraseña correcta"; mensaje.Texto = "La contraseña fue cambiada correctamente"; mensaje.Tipo = tipo; } } else if (func == 13) { if (tipo == "red") { mensaje.Titulo = "Los contraseñas no coindicen"; mensaje.Texto = "Asegurese de que las contraseñas coincidan"; mensaje.Tipo = tipo; } } else if (func == 14) { if (tipo == "red") { mensaje.Titulo = "Usuario Inactivo"; mensaje.Texto = "Contacte Al Administrador Del Sistema"; mensaje.Tipo = tipo; } } else { mensaje.Titulo = "ID Inválido"; mensaje.Texto = "el número de ID suministrado no existe"; mensaje.Tipo = "red"; } TempDataExtensions.Put <MensajesViewModel>(tempData, "mensaje", mensaje); // return mensaje; }
protected IActionResult RedirectToActionOk(string action, string controller, string message) { TempDataExtensions.SetRedirectMessage(TempData, message); TempDataExtensions.SetRedirectStatus(TempData, RedirectStatus.Success); return(RedirectToAction(action, controller)); }
public static void AccesoDenegado(this ITempDataDictionary tempData, string titulo, string texto, string tipo) { MensajesViewModel accessoDenegado = new MensajesViewModel(titulo, texto, tipo); TempDataExtensions.Put <MensajesViewModel>(tempData, "accessoDenegado", accessoDenegado); }