public async Task <ActionResult> Create(HorarioPersonaViewModel view) { try { if (ModelState.IsValid) { if (!string.IsNullOrEmpty(view.sFecha)) { view.Fecha = DateTime.ParseExact(view.sFecha, "dd/MM/yyyy", CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(view.sHora)) { view.Hora = TimeSpan.ParseExact(view.sHora, "g", CultureInfo.InvariantCulture, TimeSpanStyles.AssumeNegative); } HorarioPersona horarioPersona = new HorarioPersona(); AutoMapper.Mapper.Map(view, horarioPersona); db.HorarioPersonas.Add(horarioPersona); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } } catch (Exception) { } ViewBag.PersonaId = new SelectList(db.Personas, "PersonaId", "NombreCompleto", view.PersonaId); ViewBag.HorarioRubroId = new SelectList(db.HorarioRubros, "HorarioRubroId", "Nombre", view.HorarioRubroId); return(View(view)); }
public async Task <ActionResult> Create(InmuebleView view) { if (ModelState.IsValid) { var pic = string.Empty; var folder = "~/Content/Images"; if (view.ImagenFile != null) { pic = FilesHelper.UploadPhoto(view.ImagenFile, folder); pic = string.Format("{0}/{1}", folder, pic); } var inmueble = ToInmueble(view); inmueble.Image = pic; db.Inmuebles.Add(inmueble); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CondoID = new SelectList(db.Condominios, "CondoID", "Descripcion", view.CondoID); return(View(view)); }
public async Task <ActionResult> Create(ProductView view) { if (ModelState.IsValid) { var pic = string.Empty; var folder = "~/Content/Images"; if (view.ImageFile != null) { pic = FilesHelper.UploadPhoto(view.ImageFile, folder); pic = string.Format("{0}/{1}", folder, pic); } var product = Mappins.ProductMapping.ProductViewToProduct(view); product.Image = pic; db.Products.Add(product); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Description", view.CategoryId); return(View(view)); }
public async Task <ActionResult> Create(UserView view) { try { if (ModelState.IsValid) { var pic = string.Empty; var folder = "~/Content/Logos"; if (view.LogoFile != null) { pic = FilesHelper.UploadPhoto(view.LogoFile, folder); pic = string.Format("{0}/{1}", folder, pic); } var user = ToUser(view); user.Picture = pic; db.Users.Add(user); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.FavoriteTeamId = new SelectList(db.Teams, "TeamId", "Name", view.FavoriteTeamId); ViewBag.UserTypeId = new SelectList(db.UserTypes, "UserTypeId", "Name", view.UserTypeId); return(View(view)); } catch (Exception ex) { fileshelper.ErrorLogging(ex); return(View()); } }
public async Task <ActionResult> Create([Bind(Include = "IdPredication,Titulo,Text,UrlVideo,UrlImagen,Fecha,Sacerdote")] Predication predication) { if (ModelState.IsValid) { if (predication.UrlImagen == null) { string urlVideo = predication.UrlVideo; var uri = new Uri(urlVideo); var query = HttpUtility.ParseQueryString(uri.Query); var videoId = string.Empty; if (query.AllKeys.Contains("v")) { videoId = query["v"]; } else { videoId = uri.Segments.Last(); } String urlImagen = "https://img.youtube.com/vi/" + videoId + "/0.jpg"; predication.UrlImagen = urlImagen; } db.Predications.Add(predication); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(predication)); }
public async Task <ActionResult> Create(UserView view) { if (ModelState.IsValid) { var pic = string.Empty; var folder = "~/Content/Users"; if (view.PictureFile != null) { pic = FilesHelper.UploadPhoto(view.PictureFile, folder); pic = string.Format("{0}/{1}", folder, pic); } var user = ToUser(view); user.Picture = pic; db.Users.Add(user); await db.SaveChangesAsync(); UsersHelper.CreateUserASP(view.Email, "User", view.Password); return(RedirectToAction("Index")); } ViewBag.FavoriteLeagueId = new SelectList(db.Leagues.OrderBy(l => l.Name), "LeagueId", "Name", view.FavoriteLeagueId); ViewBag.FavoriteTeamId = new SelectList(db.Teams.Where(t => t.LeagueId == view.FavoriteLeagueId).OrderBy(t => t.Name), "TeamId", "Name", view.FavoriteTeamId); ViewBag.UserTypeId = new SelectList(db.UserTypes.OrderBy(ut => ut.Name), "UserTypeId", "Name", view.UserTypeId); return(View(view)); }
public async Task <IHttpActionResult> PutPrediction(int id, Prediction prediction) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != prediction.PredictionId) { return(BadRequest()); } _db.Entry(prediction).State = EntityState.Modified; try { await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PredictionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PutTournament(int id, Tournament tournament) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tournament.TournamentId) { return(BadRequest()); } db.Entry(tournament).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TournamentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task<ActionResult> Create([Bind(Include ="UbicationId,Description,Address,Phone,Latitude,Longitude")] Ubication ubication) { if(ModelState.IsValid) { db.Ubications.Add(ubication); await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(ubication); }
public async Task <ActionResult> Create([Bind(Include = "CustomerId,CustomerType,FirstName,LastName,Email,Phone,Address")] Customer customer) { if (ModelState.IsValid) { db.Customers.Add(customer); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(customer)); }
public async Task <ActionResult> Create([Bind(Include = "CuisineGroupId,Name")] CuisineGroup cuisineGroup) { if (ModelState.IsValid) { db.CuisineGroups.Add(cuisineGroup); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(cuisineGroup)); }
public async Task <ActionResult> Create([Bind(Include = "IngredientGroupId,Name")] IngredientGroups ingredientGroups) { if (ModelState.IsValid) { db.IngredientGroups.Add(ingredientGroups); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(ingredientGroups)); }
public async Task <ActionResult> Create([Bind(Include = "ActivitySectorId,Description,Notes")] ActivitySector activitySector) { if (ModelState.IsValid) { db.ActivitySectors.Add(activitySector); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(activitySector)); }
public async Task <ActionResult> Create([Bind(Include = "IdEvent,Titulo,Text,FechaEvento,EnlaceOnline,EnlaceInscripcion,Lugar,Hora")] Event @event) { if (ModelState.IsValid) { db.Events.Add(@event); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(@event)); }
public async Task <ActionResult> Create([Bind(Include = "LeagueId,Name,Logo")] League league) { if (ModelState.IsValid) { db.Leagues.Add(league); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(league)); }
public async Task <ActionResult> Create([Bind(Include = "IDCadena,NombreCadena")] Cadena cadena) { if (ModelState.IsValid) { db.Cadenas.Add(cadena); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(cadena)); }
public async Task <ActionResult> Create(Ubication ubication) { if (ModelState.IsValid) { db.Ubications.Add(ubication); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(ubication)); }
public async Task <ActionResult> Create([Bind(Include = "ChefId,FirstName,LastName")] Chef chef) { if (ModelState.IsValid) { db.Chefs.Add(chef); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(chef)); }
public async Task <ActionResult> Create([Bind(Include = "IDUsuario,Password,Nombre1,Nombre2,Apellido1,Apellido2,CorreoElectronico")] Usuario usuario) { if (ModelState.IsValid) { db.Usuarios.Add(usuario); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(usuario)); }
public async Task<ActionResult> Create([Bind(Include = "IngredientMergeId,Name,IngredientId")] IngredientMerge ingredientMerge) { if (ModelState.IsValid) { db.IngredientMerge.Add(ingredientMerge); await db.SaveChangesAsync(); return RedirectToAction("Index"); } ViewBag.IngredientId = new SelectList(db.Ingredientes, "IngredientId", "Name", ingredientMerge.IngredientId); return View(ingredientMerge); }
public async Task <ActionResult> Create([Bind(Include = "StatusId,Name")] Status status) { if (ModelState.IsValid) { _db.Status.Add(status); await _db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(status)); }
public async Task <ActionResult> Create(BDPersonalff bDPersonalff) { if (ModelState.IsValid) { db.BDPersonalff.Add(bDPersonalff); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(bDPersonalff)); }
public async Task <ActionResult> Create([Bind(Include = "TipoServ_ID,TipoServ_Nombre,TipoServ_Descripcion")] TiposServicios tiposServicios) { if (ModelState.IsValid) { db.TiposServicios.Add(tiposServicios); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tiposServicios)); }
public async Task <ActionResult> Create([Bind(Include = "LegalFormId,LegalFormDescription,LegalFormNotes")] LegalForm legalForm) { if (ModelState.IsValid) { db.LegalForms.Add(legalForm); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(legalForm)); }
public async Task <ActionResult> Create([Bind(Include = "DocumentTypeId,Description")] DocumentType documentType) { if (ModelState.IsValid) { db.DocumentTypes.Add(documentType); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(documentType)); }
public async Task <ActionResult> Create([Bind(Include = "UserTypeId,Name")] UserType userType) { if (ModelState.IsValid) { db.UserTypes.Add(userType); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(userType)); }
public async Task <ActionResult> Create([Bind(Include = "CategoryId,Description")] Category category) { if (ModelState.IsValid) { db.Categories.Add(category); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(category)); }
public async Task <ActionResult> Create(BoardStatus boardStatus) { if (ModelState.IsValid) { db.BoardStatus.Add(boardStatus); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(boardStatus)); }
public async Task <ActionResult> Create(Customer customer) { if (ModelState.IsValid) { db.Customers.Add(customer); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(customer)); }
public async Task <ActionResult> Create([Bind(Include = "ServiciosId,VisualizarServicio,NombreServicio,Prefijo,Impuesto,Descuentos,Afiliado,Alerta,Habilitar,ImprimirEtiqueta,Imagen")] Servicios servicios) { if (ModelState.IsValid) { db.Servicios.Add(servicios); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(servicios)); }