public async Task <IActionResult> PutPagamento(int id, Pagamento pagamento) { int index = produto.FindIndex(p => p.IdPagto == id); pagamento.IdPagto = id; if (id != pagamento.IdPagto) { //return BadRequest(); } _context.Entry(pagamento).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PagamentoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task RemoveProduct(int id) { var productToRemove = db.Products.Where(p => p.Id == id).FirstOrDefault(); db.Products.Remove(productToRemove); await db.SaveChangesAsync(); }
public async Task <IActionResult> PutOffre(string id, Offre offre) { if (id != offre.Id_offre) { return(BadRequest()); } _context.Entry(offre).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OffreExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutFavoriteBook([FromRoute] int id, [FromBody] FavoriteBook favoriteBook) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != favoriteBook.id) { return(BadRequest()); } _context.Entry(favoriteBook).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FavoriteBookExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPersona(int id, Persona persona) { if (id != persona.Id) { return(BadRequest()); } _context.Entry(persona).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("FullName,Upload,Photo,Id,Profession,Description")] HomeTestimonial homeTestimonial) { if (homeTestimonial.Upload == null) { ModelState.AddModelError("Upload", "Şəkil məcburidir"); } else { if (homeTestimonial.Upload.ContentType != "image/jpeg" && homeTestimonial.Upload.ContentType != "image/png" && homeTestimonial.Upload.ContentType != "image/gif") { ModelState.AddModelError("Upload", "Siz yalnız png,jpg və ya gif faylı yükləyə bilərsiniz"); } if (homeTestimonial.Upload.Length > 1048576) { ModelState.AddModelError("Upload", "Fayl ölcüsu maximum 1MB ola bilər"); } } if (ModelState.IsValid) { var fileName = _fileManager.Upload(homeTestimonial.Upload); homeTestimonial.Photo = fileName; _context.Add(homeTestimonial); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(homeTestimonial)); }
public async Task <IActionResult> PutEmpleado(int id, Empleado empleado) { if (id != empleado.IdEmpleado) { return(BadRequest()); } _context.Entry(empleado).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmpleadoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Title,Upload,Photo,Id,Content,Description,Link,TextStyleLeft,TextStyleRight,Status")] FashionSlider fashion) { if (fashion.Upload == null) { ModelState.AddModelError("Upload", "The Photo field is required."); } else { if (fashion.Upload.ContentType != "image/jpeg" && fashion.Upload.ContentType != "image/png" && fashion.Upload.ContentType != "image/gif") { ModelState.AddModelError("Upload", "You can only download png, jpg or gif file"); } if (fashion.Upload.Length > 1048576) { ModelState.AddModelError("Upload", "The file size can be a maximum of 1 MB"); } } if (ModelState.IsValid) { var fileName = _fileManager.Upload(fashion.Upload); fashion.Photo = fileName; _context.Add(fashion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(fashion)); }
public async Task <IActionResult> PutGame(int id, Game game) { if (id != game.GameId) { return(BadRequest()); } _context.Entry(game).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GameExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutFavorite(int id, Favoris favorite) { if (id != favorite.Id_candidat) { return(BadRequest()); } _context.Entry(favorite).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FavoriteExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Title,Upload,Photo,Id")] TestimonialItem testimonial) { if (testimonial.Upload == null) { ModelState.AddModelError("Upload", "The Photo field is required."); } else { if (testimonial.Upload.ContentType != "image/jpeg" && testimonial.Upload.ContentType != "image/png" && testimonial.Upload.ContentType != "image/gif") { ModelState.AddModelError("Upload", "You can only download png, jpg or gif file"); } if (testimonial.Upload.Length > 1048576) { ModelState.AddModelError("Upload", "The file size can be a maximum of 1 MB"); } } if (ModelState.IsValid) { var fileName = _fileManager.Upload(testimonial.Upload); testimonial.Photo = fileName; _context.Add(testimonial); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(testimonial)); }
public async Task <IActionResult> PutContact(int id, Contact contact) { if (id != contact.Id_contact) { return(BadRequest()); } _context.Entry(contact).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,Title,Description,Photo,PublishDate,IsPublished,CreateDate,CreatedBy,UpdateDate,UpdatedBy,CategoryId")] News news, IFormFile upload) { //dosya uzantısı ıcın gecerliik denetimi if (upload != null && !IsExtensionValid(upload)) { ModelState.AddModelError("Photo", "Dosya uzantısı jpg, jpeg ,gif , png olmalıdır."); } else if (upload == null) { ModelState.AddModelError("Photo", "Resim yüklemeniz gerekmektedir"); } if (ModelState.IsValid) { news.CreateDate = DateTime.Now; news.CreatedBy = User.Identity.Name; news.UpdateDate = DateTime.Now; news.UpdatedBy = User.Identity.Name; news.PublishDate = DateTime.Now; //dosya yuklemesi if (upload != null && upload.Length > 0 && IsExtensionValid(upload)) { news.Photo = await UploadFileAsync(upload); } _context.Add(news); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", news.CategoryId); return(View(news)); }
public async Task <IActionResult> PutRappel(int id, Rappel rappel) { if (id != rappel.Id_rappel) { return(BadRequest()); } _context.Entry(rappel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RappelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task SaveRespuestaCuestionario(RespuestaCuestionario respuestaCuestionario) { respuestaCuestionario.Activo = 1; respuestaCuestionario.Fecha = DateTime.Now; _context.Add(respuestaCuestionario); await _context.SaveChangesAsync(); }
public async Task <IActionResult> PutItem(int id, Item item) { if (id != item.ItemId) { return(BadRequest()); } item.ModifiedAt = DateTime.Now; _context.Entry(item).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCategory(int id, Category category) { if (id != category.CategoryId) { return(BadRequest()); } category.ModifiedAt = DateTime.Now; _context.Entry(category).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Name,Upload,Photo,Id,ProductCount")] Kapee.Models.Category.Category category) { if (category.Upload == null) { ModelState.AddModelError("Upload", "The Photo field is required."); } else { if (category.Upload.ContentType != "image/jpeg" && category.Upload.ContentType != "image/png" && category.Upload.ContentType != "image/gif") { ModelState.AddModelError("Upload", "You can only download png, jpg or gif file"); } if (category.Upload.Length > 1048576) { ModelState.AddModelError("Upload", "The file size can be a maximum of 1 MB"); } } if (ModelState.IsValid) { var fileName = _fileManager.Upload(category.Upload); category.Photo = fileName; _context.Add(category); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Create([Bind("Id,Upload,Photo,ProductId")] BigSizePhoto bigsizePhoto) { if (bigsizePhoto.Upload == null) { ModelState.AddModelError("Upload", "The Photo field is required."); } else { if (bigsizePhoto.Upload.ContentType != "image/jpeg" && bigsizePhoto.Upload.ContentType != "image/png" && bigsizePhoto.Upload.ContentType != "image/gif") { ModelState.AddModelError("Upload", "You can only download png, jpg or gif file"); } if (bigsizePhoto.Upload.Length > 1048576) { ModelState.AddModelError("Upload", "The file size can be a maximum of 1 MB"); } } if (ModelState.IsValid) { var fileName = _fileManager.Upload(bigsizePhoto.Upload); bigsizePhoto.Photo = fileName; _context.Add(bigsizePhoto); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", bigsizePhoto.ProductId); return(View(bigsizePhoto)); }
public async Task <IActionResult> Create([Bind("Upload,Photo,Id")] AboutChooseUs aboutChooseUs) { if (aboutChooseUs.Upload == null) { ModelState.AddModelError("Upload", "Şəkil məcburidir"); } else { if (aboutChooseUs.Upload.ContentType != "image/jpeg" && aboutChooseUs.Upload.ContentType != "image/png" && aboutChooseUs.Upload.ContentType != "image/gif") { ModelState.AddModelError("Upload", "Siz yalnız png,jpg və ya gif faylı yükləyə bilərsiniz"); } if (aboutChooseUs.Upload.Length > 1048576) { ModelState.AddModelError("Upload", "Fayl ölcüsu maximum 1MB ola bilər"); } } if (ModelState.IsValid) { var fileName = _fileManager.Upload(aboutChooseUs.Upload); aboutChooseUs.Photo = fileName; _context.Add(aboutChooseUs); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(aboutChooseUs)); }
public async Task <IActionResult> PutSpeaker(int id, Speaker speaker) { if (id != speaker.Id) { return(BadRequest()); } _context.Entry(speaker).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpeakerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTarjetaCredito(int id, TarjetaCredito tarjetaCredito) { if (id != tarjetaCredito.Id) { return(BadRequest()); } _context.Entry(tarjetaCredito).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TarjetaCreditoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,Email,Password,ConfirmPassword,CreateDate,CreateBy,UpdateDate,UpdateBy")] User user) { Security.LoginCheck(HttpContext); if (ModelState.IsValid) { user.UpdateDate = DateTime.Now; user.UpdateBy = User.Identity.Name; user.Password = Convert.ToBase64String(SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(user.Password))); try { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (ArgumentException ex) { //argument hatasından burası calısır. ModelState.AddModelError("Email", "Bu eposta adresi daha önce kullanılmış."); } catch (Exception ex) { //genel herhangibir hata olursa burası calısır argument hatası harıcınde } finally { //her zaman calısır. hata olmasa bile. } } return(View(user)); }
public async Task <IActionResult> Create(ClassRoom temp) { if (ModelState.IsValid) { _Context.ClassRoomList.Add(temp); await _Context.SaveChangesAsync(); } return(View("Index", await _Context.ClassRoomList.ToListAsync())); }
public async Task <IActionResult> Create([Bind("Id,Title,Content")] AboutChooseUsItem aboutChooseUsItem) { if (ModelState.IsValid) { _context.Add(aboutChooseUsItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(aboutChooseUsItem)); }
public async Task <IActionResult> Create([Bind("Id,Nombre")] ResponsableZonal responsableZonal) { if (ModelState.IsValid) { _context.Add(responsableZonal); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(responsableZonal)); }
public async Task <IActionResult> Create([Bind("Id,Title,Content,Text")] HomeSpecialitySucces homeSuccess) { if (ModelState.IsValid) { _context.Add(homeSuccess); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(homeSuccess)); }
public async Task <IActionResult> Create([Bind("IdCli,Nome,Cpf,Contrato,Data,Valor_principal,Valor_atualizado")] Cliente cliente) { if (ModelState.IsValid) { _context.Add(cliente); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cliente)); }
public async Task <IActionResult> Create([Bind("Id,Nombre,Apellido,Direccion")] Clientes clientes) { if (ModelState.IsValid) { _context.Add(clientes); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(clientes)); }
public async Task <IActionResult> Create([Bind("Id,Facebook,Twitter,Linkedin,Yotube")] SocialLink socialLink) { if (ModelState.IsValid) { _context.Add(socialLink); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(socialLink)); }