public IActionResult Register() { //Block for Registration Error Checking Microsoft.AspNetCore.Http.IFormCollection nvc = Request.Form; //source https://stackoverflow.com/questions/564289/read-post-data-submitted-to-asp-net-form string userName = "", password = "", email = ""; bool UNSet = false, PWSet = false, ESet = false; if (!string.IsNullOrEmpty(nvc["RegisterUsername"])) { userName = nvc["RegisterUsername"]; UNSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["RegisterPassword"])) { if (nvc["RegisterPassword"] == nvc["RegisterConfirmPassword"]) { password = nvc["RegisterPassword"]; PWSet = true; } } { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["RegisterEmail"])) { email = nvc["RegisterEmail"]; ESet = true; } else { RedirectToAction("Error", "Home"); } //End Registration Error Check Block if (UNSet == true && PWSet == true && ESet == true) { User newUser = new User(userName, password, email); DatabaseContext.Add(newUser); DatabaseContext.SaveChanges(); } else { RedirectToAction("Error", "Home"); } var context = new mypartysite.Model.Current(); var currEvent = context.initialize(); return(RedirectToAction("RegisterSuccess", "Home")); }
public async Task <IActionResult> AddAutor(Guid idLibro, Microsoft.AspNetCore.Http.IFormCollection form) { var idAutor = new Guid(form["idAutor"]); if (!_context.AutoresLibros.Any(x => x.IdAutor == idAutor && x.IdLibro == idLibro)) { var autorLibro = new AutorLibro() { IdAutor = idAutor, IdLibro = idLibro }; _context.AutoresLibros.Add(autorLibro); await _context.SaveChangesAsync(); } var libro = await _context.Libros.FindAsync(idLibro); libro.AutoresLibros = await _context.AutoresLibros.Where(x => x.IdLibro == idLibro).ToListAsync(); ViewData["IdEditorial"] = new SelectList(_context.Editoriales, "IdEditorial", "Nombre", libro.IdEditorial); ViewData["IdGenero"] = new SelectList(_context.Generos, "IdGenero", "Nombre", libro.IdGenero); ViewData["IdPais"] = new SelectList(_context.Paises, "IdPais", "Nombre", libro.IdPais); ViewData["Autores"] = new SelectList(_context.Autores, "IdAutor", "Nombre"); libro.Portada = DescargarImagen(libro.Imagen); return(View("Edit", libro)); }
public IActionResult Login() { Microsoft.AspNetCore.Http.IFormCollection nvc = Request.Form; //source https://stackoverflow.com/questions/564289/read-post-data-submitted-to-asp-net-form string userName = "", password = ""; bool UNSet = false, PWSet = false; if (!string.IsNullOrEmpty(nvc["LoginUsername"])) { userName = nvc["LoginUsername"]; UNSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["LoginPassword"])) { password = nvc["LoginPassword"]; PWSet = true; } else { RedirectToAction("Error", "Home"); } bool userFound = false; if (PWSet == true && UNSet == true) { User loggingIn = new User(userName, password); var users = DatabaseContext.Users.ToList(); foreach (User alpha in users) { if (alpha.UserName == loggingIn.UserName && alpha.Password == loggingIn.Password) { userFound = true; } } } if (userFound == true) { return(RedirectToAction("Success", "Home")); } else { return(RedirectToAction("Error", "Home")); } }
/// <summary> /// Process a list of items according to Form data parameters /// </summary> /// <param name="lstElements">list of elements</param> /// <param name="requestFormData">collection of form data sent from client side</param> /// <returns>list of items processed</returns> private List <Models.Item> ProcessCollection(List <Models.Item> lstElements, Microsoft.AspNetCore.Http.IFormCollection requestFormData) { string searchText = string.Empty; Microsoft.Extensions.Primitives.StringValues tempOrder = new[] { "" }; if (requestFormData.TryGetValue("search[value]", out tempOrder)) { searchText = requestFormData["search[value]"].ToString(); } tempOrder = new[] { "" }; var skip = Convert.ToInt32(requestFormData["start"].ToString()); var pageSize = Convert.ToInt32(requestFormData["length"].ToString()); if (requestFormData.TryGetValue("order[0][column]", out tempOrder)) { var columnIndex = requestFormData["order[0][column]"].ToString(); var sortDirection = requestFormData["order[0][dir]"].ToString(); tempOrder = new[] { "" }; if (requestFormData.TryGetValue($"columns[{columnIndex}][data]", out tempOrder)) { var columName = requestFormData[$"columns[{columnIndex}][data]"].ToString(); if (pageSize > 0) { var prop = GetProperty(columName); if (sortDirection == "asc") { return(lstElements .Where(x => x.Name.ToLower().Contains(searchText.ToLower()) || x.Description.ToLower().Contains(searchText.ToLower())) .Skip(skip) .Take(pageSize) .OrderBy(prop.GetValue).ToList()); } else { return(lstElements .Where( x => x.Name.ToLower().Contains(searchText.ToLower()) || x.Description.ToLower().Contains(searchText.ToLower())) .Skip(skip) .Take(pageSize) .OrderByDescending(prop.GetValue).ToList()); } } else { return(lstElements); } } } return(null); }
public async Task <IActionResult> Upload() { Microsoft.AspNetCore.Http.IFormCollection formCollection = Request.Form; Microsoft.AspNetCore.Http.IFormFileCollection formFiles = formCollection.Files; var uploads = Path.Combine(he.WebRootPath, "docs"); String DocsRutaNombreArchivo = ""; //Boolean fileUploaded = false; var ventaRequisito = await DB.Ventas_VentaRequisito.FindAsync(0); for (var i = 0; i < formFiles.Count; i++) { if (i == 0) { var file = formFiles[i]; if (file.Length > 0) { Int32 IdVentaRequisito = Convert.ToInt32(file.FileName.Replace(".pdf", "")); var GeneraNombreArchivo = DB.Generales_fRetornaCadena.FromSql($"SELECT * FROM \"Ventas\".\"fGeneraNombreDocumento\"({IdVentaRequisito})").ToList(); String NombreArchivo = GeneraNombreArchivo.FirstOrDefault().Cadena; DocsRutaNombreArchivo += NombreArchivo; var filePath = Path.Combine(uploads, NombreArchivo); using (var fileStream = new FileStream(filePath, FileMode.Create)) { await file.CopyToAsync(fileStream); //fileUploaded = true; } ventaRequisito = await DB.Ventas_VentaRequisito.FindAsync(IdVentaRequisito); ventaRequisito.PathArchivo = DocsRutaNombreArchivo; ventaRequisito.ArchivoCargado = true; DB.Update(ventaRequisito); await DB.SaveChangesAsync(); } } } //return fileUploaded; return(View(ventaRequisito)); }
public IActionResult Login() { Microsoft.AspNetCore.Http.IFormCollection nvc = Request.Form; //source https://stackoverflow.com/questions/564289/read-post-data-submitted-to-asp-net-form string userName = "", password = ""; bool UNSet = false, PWSet = false; if (!string.IsNullOrEmpty(nvc["LoginUsername"])) { userName = nvc["LoginUsername"]; UNSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["LoginPassword"])) { password = nvc["LoginPassword"]; PWSet = true; } else { RedirectToAction("Error", "Home"); } bool userFound = false; if (PWSet == true && UNSet == true) { User loggingIn = new User(userName, password); var users = DatabaseContext.Users.ToList(); /* * must use these methods to set cookies: * HttpContext.Session.SetString("Name", "Mike"); * HttpContext.Session.SetInt32("Age", 21); */ foreach (User alpha in users) { if (alpha.UserName == loggingIn.UserName && alpha.Password == loggingIn.Password) { userFound = true; HttpContext.Session.SetString("LoggedInQ", "True"); HttpContext.Session.SetString("UserName", alpha.UserName); HttpContext.Session.SetString("SecurityLevel", alpha.securityLevel); HttpContext.Session.SetInt32("UserID", alpha.UserId); HttpContext.Session.SetString("Email", alpha.email); } } } var LoggedInQ = HttpContext.Session.Get("LoggedInQ"); string sLoggedInQ = Encoding.ASCII.GetString(LoggedInQ, 0, LoggedInQ.Length); ViewBag.LoggedInQ = sLoggedInQ; var UserName = HttpContext.Session.Get("UserName"); string sUserName = Encoding.ASCII.GetString(UserName, 0, UserName.Length); ViewBag.UserName = sUserName; var SecurityLevel = HttpContext.Session.Get("SecurityLevel"); string sSecurityLevel = Encoding.ASCII.GetString(SecurityLevel, 0, SecurityLevel.Length); ViewBag.SecurityLevel = sSecurityLevel; var UserID = HttpContext.Session.Get("UserID"); string sUserID = Encoding.ASCII.GetString(UserID, 0, UserID.Length); ViewBag.UserID = sUserID; var Email = HttpContext.Session.Get("Email"); string sEmail = Encoding.ASCII.GetString(Email, 0, Email.Length); ViewBag.Email = sEmail; if (userFound == true) { return(RedirectToAction("LoginSuccess", "Home")); } else { return(RedirectToAction("Error", "Home")); } }
public void Delete(Microsoft.AspNetCore.Http.IFormCollection fc) { string a = fc["foo"]; }
public IActionResult RequestEventPost() //user submit request should handle post { Microsoft.AspNetCore.Http.IFormCollection nvc = Request.Form; //source https://stackoverflow.com/questions/564289/read-post-data-submitted-to-asp-net-form //values for object initialization string eventName = "", eventDate = "", venueName = "", venueAddress = "", venueUnspecified = "", eventDescription = "", eventNumOfGuest = "", eventComments = "", floorPlanSpecified = "", liveEntertainment = "", eventStage = "", eventAudio = "", eventVideo = ""; //controls //bool UNSet = false, PWSet = false, ESet = false; bool ENSet = false, EDateSet = false, VNSet = false, VASet = false, VUSet = false, EDescSet = false, ENogSet = false, ECSet = false, FSSet = false, LESet = false, EStageSet = false, EASet = false, EVSet = false; //logic camelCase strings are to hold values the other case names are corresponding to name field in cshtml if (!string.IsNullOrEmpty(nvc["EventName"])) { eventName = nvc["EventName"]; ENSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventDate"])) { eventDate = nvc["EventDate"]; EDateSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["VenueName"])) { venueName = nvc["VenueName"]; VNSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["VenueAddress"])) { venueAddress = nvc["VenueAddress"]; VASet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["VenueUnspecified"])) { venueUnspecified = nvc["VenueUnspecified"]; VUSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventDescription"])) { eventDescription = nvc["EventDescription"]; EDescSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventNumOfGuest"])) { eventNumOfGuest = nvc["EventNumOfGuest"]; ENogSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventComments"])) { eventComments = nvc["EventComments"]; ECSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["FloorplanSpecified"])) { floorPlanSpecified = nvc["FloorplanSpecified"]; FSSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["LiveEntertainment"])) { liveEntertainment = nvc["LiveEntertainment"]; LESet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventStage"])) { eventStage = nvc["EventStage"]; EStageSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventAudio"])) { eventAudio = nvc["EventAudio"]; EASet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventVideo"])) { eventVideo = nvc["EventVideo"]; EVSet = true; } else { RedirectToAction("Error", "Home"); } return(RedirectToAction("RequestStatus", "Home")); }
public IActionResult Find(Microsoft.AspNetCore.Http.IFormCollection elements) { List <Transaction> transactions = new List <Transaction>(); transactions.AddRange(td.Find(DateTime.Parse(elements["dpFilter"].ToString()), int.Parse(elements["Taquilla"].ToString()))); List <Transaction> transactionsTem = new List <Transaction>(transactions.Count); transactions.ForEach((item) => transactionsTem.Add(item.Clone())); foreach (Transaction transaction in transactionsTem) { foreach (Product producto in producManager.GetAllAsync().Result.ToList()) { foreach (ActionType action in actionManager.GetAllAsync().Result.ToList()) { TransactionDetail tem = new TransactionDetail() { Product = new Product() { IdProduct = producto.IdProduct, Description = producto.Description }, MovementType = new ActionType() { IdTipoMovimiento = action.IdTipoMovimiento, Description = action.Description }, Transaction = new Transaction() { Id = transaction.Id }, Quantity = 0, Price = 0, }; if (transactions.Where(t => t.Id == transaction.Id).ToList().Count > 0) { if (transactions.Where(t => t.Id == transaction.Id).First().TransactionDetail.Where(m => m.ProductId == producto.IdProduct && m.MovementTypeId == action.IdTipoMovimiento).ToList().Count > 0) { TransactionDetail tl = transactions.Where(t => t.Id == transaction.Id).First().TransactionDetail.Where(m => m.ProductId == producto.IdProduct && m.MovementTypeId == action.IdTipoMovimiento).First(); tem.Id = tl.Id; tem.InvalidValue = tl.InvalidValue; tem.Price = tl.Price; tem.Quantity = tl.Quantity; tem.Transaction = tl.Transaction; tem.InvalidValue = tl.InvalidValue; tem.Transaction = new Transaction() { Id = transaction.Id }; } } if (producto.IdProduct != 3) { transaction.TransactionDetail.Add(tem); } else if (producto.IdProduct == action.IdTipoMovimiento) { transaction.TransactionDetail.Add(tem); } } } } TempData["TicketOffices"] = (List <SelectListItem>)lst.ConvertAll(d => { return(new SelectListItem() { Value = d.Id.ToString(), Text = d.Description }); }); return(View("~/Views/Admin/Index.cshtml", transactionsTem)); }
public IActionResult RequestEventPost() //user submit request should handle post { bool Logged = isUserLoggedIn(); if (Logged == false) { ViewBag.LoggedInQ = "False"; } //Acquire user ID for updating event var UserID = HttpContext.Session.Get("UserID"); string sUserID = Encoding.ASCII.GetString(UserID, 0, UserID.Length); ViewBag.UserID = sUserID; Microsoft.AspNetCore.Http.IFormCollection nvc = Request.Form; //source https://stackoverflow.com/questions/564289/read-post-data-submitted-to-asp-net-form //values for object initialization string eventName = "", eventDate = "", venueName = "", venueAddress = "", venueUnspecified = "", eventDescription = "", eventNumOfGuest = "", eventComments = "", floorPlanSpecified = "", liveEntertainment = "", eventStage = "", eventAudio = "", eventVideo = ""; //controls - the commented out ones are not used for initializations in the current state of application bool ENSet = false, EDateSet = false, VNSet = false, VASet = false, /* VUSet = false, */ EDescSet = false, ENogSet = false, ECSet = false, /* FSSet = false, */ /*LESet = false, */ EStageSet = false, EASet = false, EVSet = false; //logic camelCase strings are to hold values the other case names are corresponding to name field in cshtml if (!string.IsNullOrEmpty(nvc["EventName"])) { eventName = nvc["EventName"]; ENSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventDate"])) { eventDate = nvc["EventDate"]; EDateSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["VenueName"])) { venueName = nvc["VenueName"]; VNSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["VenueAddress"])) { venueAddress = nvc["VenueAddress"]; VASet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["VenueUnspecified"])) { venueUnspecified = nvc["VenueUnspecified"]; //VUSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventDescription"])) { eventDescription = nvc["EventDescription"]; EDescSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventNumOfGuest"])) { eventNumOfGuest = nvc["EventNumOfGuest"]; ENogSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventComments"])) { eventComments = nvc["EventComments"]; ECSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["FloorplanSpecified"])) { floorPlanSpecified = nvc["FloorplanSpecified"]; //FSSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["LiveEntertainment"])) { liveEntertainment = nvc["LiveEntertainment"]; //LESet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventStage"])) { eventStage = nvc["EventStage"]; EStageSet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventAudio"])) { eventAudio = nvc["EventAudio"]; EASet = true; } else { RedirectToAction("Error", "Home"); } if (!string.IsNullOrEmpty(nvc["EventVideo"])) { eventVideo = nvc["EventVideo"]; EVSet = true; } else { RedirectToAction("Error", "Home"); } if (ENSet == true && EDateSet == true && VNSet == true && VASet == true && EDescSet == true && ENogSet == true && ECSet == true && EStageSet == true && EASet == true && EVSet == true) { Event newEvent = new Event(eventName, eventDate, venueName, venueAddress, eventDescription, eventComments, eventNumOfGuest, eventStage, eventAudio, eventVideo, sUserID); DatabaseContext.Add(newEvent); DatabaseContext.SaveChanges(); } else { RedirectToAction("Error", "Home"); } return(RedirectToAction("RequestStatus", "Home")); }
public IActionResult EventRequestsPost() { //logged in / out checking bool Logged = isUserLoggedIn(); if (Logged == false) { ViewBag.LoggedInQ = "False"; } //obtain security level of logged in user var SecurityLevel = HttpContext.Session.Get("SecurityLevel"); string sSecurityLevel = Encoding.ASCII.GetString(SecurityLevel, 0, SecurityLevel.Length); ViewBag.SecurityLevel = sSecurityLevel; var isUserAdmin = sSecurityLevel; if (isUserAdmin != "admin") { return(RedirectToAction("Error", "Home")); } Microsoft.AspNetCore.Http.IFormCollection nvc = Request.Form; string result = ""; //bool? accepted = null, denied = null; if (!string.IsNullOrEmpty(nvc["Accepted"])) { result = nvc["Accepted"]; //accepted = true; } if (!string.IsNullOrEmpty(nvc["Denied"])) { result = nvc["Denied"]; //denied = true; } if (!string.IsNullOrEmpty(nvc["Awaiting Approval"])) { result = nvc["Awaiting Approval"]; } if (!string.IsNullOrEmpty(nvc["Delete"])) { result = nvc["Delete"]; } Event toUpdate = new Event(); var table = DatabaseContext.Events; foreach (Event alpha in table) { if (alpha.Name == nvc["EventName"]) { toUpdate = alpha; } } /* DatabaseContext.Update(toUpdate).Member(toUpdate.AcceptedQ).EntityEntry. */ if (result == "Accepted") //implementation source: https://stackoverflow.com/questions/3642371/how-to-update-only-one-field-using-entity-framework { toUpdate.AcceptedQ = "Accepted"; DatabaseContext.Events.Attach(toUpdate); DatabaseContext.Entry(toUpdate).Property(x => x.AcceptedQ).IsModified = true; DatabaseContext.SaveChanges(); } else if (result == "Denied") { toUpdate.AcceptedQ = "Denied"; DatabaseContext.Events.Attach(toUpdate); DatabaseContext.Entry(toUpdate).Property(x => x.AcceptedQ).IsModified = true; DatabaseContext.SaveChanges(); } else if (result == "Delete") { DatabaseContext.Events.Remove(toUpdate); DatabaseContext.SaveChanges(); } else if (result == "Awaiting Approval") { toUpdate.AcceptedQ = "Awaiting Approval"; DatabaseContext.Events.Attach(toUpdate); DatabaseContext.Entry(toUpdate).Property(x => x.AcceptedQ).IsModified = true; DatabaseContext.SaveChanges(); } return(RedirectToAction("EventRequests", "Home")); }