Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ProductName,Price,Category,Unidad,Fecha_Registro,Path_Imagen")] Producto producto)
        {
            if (id != producto.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(producto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductoExists(producto.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(producto));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre")] ResponsableZonal responsableZonal)
        {
            if (id != responsableZonal.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(responsableZonal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ResponsableZonalExists(responsableZonal.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(responsableZonal));
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdCli,Nome,Cpf,Contrato,Data,Valor_principal,Valor_atualizado")] Cliente cliente)
        {
            if (id != cliente.IdCli)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cliente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClienteExists(cliente.IdCli))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdPagto,IdCli,Cpf,Contrato,Parcela,Data,Valor,Desconto,Situacao")] Pagamento pagamento)
        {
            if (id != pagamento.IdPagto)
            {
                //return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pagamento);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PagamentoExists(pagamento.IdPagto))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCli"] = new SelectList(_context.Cliente, "IdCli", "IdCli", pagamento.IdCli);
            //return RedirectToAction("Details/" + pagamento.IdCli + "", "Cliente");
            return(View(pagamento));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Content")] AboutChooseUsItem aboutChooseUsItem)
        {
            if (id != aboutChooseUsItem.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(aboutChooseUsItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AboutChooseUsItemExists(aboutChooseUsItem.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(aboutChooseUsItem));
        }
Example #6
0
        public async Task <IActionResult> Edit(int?id, [Bind("Id,Name,CategoryId")] SubCategory subCategory)
        {
            if (id != subCategory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(subCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubCategoryExists(subCategory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", subCategory.CategoryId);

            return(View(subCategory));
        }
Example #7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre,Apellido,Direccion")] Clientes clientes)
        {
            if (id != clientes.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(clientes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientesExists(clientes.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(clientes));
        }
Example #8
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Email,Password,CreateDate,CreateBy,UpdateDate,UpdateBy")] User user)
        {
            Security.LoginCheck(HttpContext);
            if (id != user.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    user.UpdateDate = DateTime.Now;
                    user.UpdateBy   = User.Identity.Name;

                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Example #9
0
        public async Task <IActionResult> Edit(int?id, [Bind("Id,Title,Content,Icon")] Info info)
        {
            if (id != info.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(info);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InfoExists(info.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(info));
        }
Example #10
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Address,Phone,Email")] Setting setting)
        {
            if (id != setting.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(setting);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SettingExists(setting.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(setting));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Facebook,Twitter,Linkedin,Yotube")] SocialLink socialLink)
        {
            if (id != socialLink.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(socialLink);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SocialLinkExists(socialLink.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(socialLink));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Content,Text")] HomeSpecialitySucces homeSuccess)
        {
            if (id != homeSuccess.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(homeSuccess);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HomeSuccessExists(homeSuccess.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(homeSuccess));
        }
Example #13
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Capital,Intereses,Periodo,ClientesId")] Prestamo prestamo)
        {
            if (id != prestamo.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(prestamo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PrestamoExists(prestamo.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClientesId"] = new SelectList(_context.Clientes, "Id", "Apellido", prestamo.ClientesId);
            return(View(prestamo));
        }
Example #14
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,CreateDate,CreatedBy,UpdateDate,UpdatedBy")] Category category)
        {
            if (id != category.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    category.UpdateDate = DateTime.Now;
                    category.UpdatedBy  = User.Identity.Name;


                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Upload,Photo,ProductId")] BigSizePhoto bigsizePhoto)
        {
            if (id != bigsizePhoto.Id)
            {
                return(NotFound());
            }

            if (bigsizePhoto.Upload == null)
            {
                ModelState.AddModelError("Upload", "The Photo field is required.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (bigsizePhoto.Upload != null)
                    {
                        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");
                            return(View(bigsizePhoto));
                        }

                        if (bigsizePhoto.Upload.Length > 1048576)
                        {
                            ModelState.AddModelError("Upload", "The file size can be a maximum of 1 MB");
                            return(View(bigsizePhoto));
                        }

                        var oldFile = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "uploads", bigsizePhoto.Photo);
                        _fileManager.Delete(oldFile);

                        var fileName = _fileManager.Upload(bigsizePhoto.Upload, "wwwroot/uploads");
                        bigsizePhoto.Photo = fileName;
                    }

                    _context.Update(bigsizePhoto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BigsizePhotoExsist(bigsizePhoto.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", bigsizePhoto.ProductId);

            return(View(bigsizePhoto));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Upload,Photo,Id")] HomeBrand homeBrand)
        {
            if (id != homeBrand.Id)
            {
                return(NotFound());
            }

            if (homeBrand.Upload == null)
            {
                ModelState.AddModelError("Upload", "Şəkil məcburidir");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (homeBrand.Upload != null)
                    {
                        if (homeBrand.Upload.ContentType != "image/jpeg" && homeBrand.Upload.ContentType != "image/png" && homeBrand.Upload.ContentType != "image/gif")
                        {
                            ModelState.AddModelError("Upload", "Siz yalnız png,jpg və ya gif faylı yükləyə bilərsiniz");
                            return(View(homeBrand));
                        }


                        if (homeBrand.Upload.Length > 1048576)
                        {
                            ModelState.AddModelError("Upload", "Fayl ölcüsu maximum 1MB ola bilər");
                            return(View(homeBrand));
                        }

                        var oldFile = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "uploads", homeBrand.Photo);
                        _fileManager.Delete(oldFile);

                        var fileName = _fileManager.Upload(homeBrand.Upload, "wwwroot/uploads");
                        homeBrand.Photo = fileName;
                    }

                    _context.Update(homeBrand);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HomeBrandExsist(homeBrand.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(homeBrand));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Title,Upload,Photo,Id,Content,Description,Link,TextStyleLeft,TextStyleRight,Status")] FashionSlider fashion)
        {
            if (id != fashion.Id)
            {
                return(NotFound());
            }

            if (fashion.Upload == null)
            {
                ModelState.AddModelError("Upload", "The Photo field is required.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (fashion.Upload != null)
                    {
                        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");
                            return(View(fashion));
                        }

                        if (fashion.Upload.Length > 1048576)
                        {
                            ModelState.AddModelError("Upload", "The file size can be a maximum of 1 MB");
                            return(View(fashion));
                        }

                        var oldFile = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "uploads", fashion.Photo);
                        _fileManager.Delete(oldFile);

                        var fileName = _fileManager.Upload(fashion.Upload, "wwwroot/uploads");
                        fashion.Photo = fileName;
                    }

                    _context.Update(fashion);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FashionExsist(fashion.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(fashion));
        }
Example #18
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,Upload,Photo,Id,ProductCount")] Kapee.Models.Category.Category category)
        {
            if (id != category.Id)
            {
                return(NotFound());
            }

            if (category.Upload == null)
            {
                ModelState.AddModelError("Upload", "The Photo field is required.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (category.Upload != null)
                    {
                        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");
                            return(View(category));
                        }

                        if (category.Upload.Length > 1048576)
                        {
                            ModelState.AddModelError("Upload", "The file size can be a maximum of 1 MB");
                            return(View(category));
                        }

                        var oldFile = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "uploads", category.Photo);
                        _fileManager.Delete(oldFile);

                        var fileName = _fileManager.Upload(category.Upload, "wwwroot/uploads");
                        category.Photo = fileName;
                    }

                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CateforyExsist(category.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Example #19
0
        public async Task <IActionResult> Edit(Usuario usuario)
        {
            if (ModelState.IsValid)
            {
                _context.Update(usuario);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(usuario));
        }
        public IActionResult Editar(Hospedagem hospedagem)
        {
            if (ModelState.IsValid)
            {
                _context.Update(hospedagem);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View());
        }
        public IActionResult Editar(Atracoes atracoes)
        {
            if (ModelState.IsValid)
            {
                _context.Update(atracoes);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View());
        }
Example #22
0
        public async Task <IActionResult> Edit(NewContractorClass ncc)
        {
            if (ModelState.IsValid)
            {
                _db.Update(ncc);
                await _db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(ncc));
        }
        [ValidateAntiForgeryToken]                              //metodo para las peticiones tipo post - nos protege los formularios validando un token
        public async Task <IActionResult> Edit(Usuario usuario) //instanciar usuario
        {
            //si el modelo es valido (que los campos requeridos/resticciones se cumplan (data annotations).
            if (ModelState.IsValid)
            {
                _context.Update(usuario);
                await _context.SaveChangesAsync();// siempre que utilizamos un metodo async debemos utilizar await

                return(RedirectToAction(nameof(Index)));
            }
            return(View(usuario));
        }
Example #24
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description,Photo,PublishDate,IsPublished,CreateDate,CreatedBy,UpdateDate,UpdatedBy,CategoryId")] News news, IFormFile upload)
        {
            if (id != news.Id)
            {
                return(NotFound());
            }

            //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 && news.Photo == null)//eger resim yüklenmisse bir daha sectirmiyor
            {
                ModelState.AddModelError("Photo", "Resim yüklemeniz gerekmektedir");
            }



            if (ModelState.IsValid)
            {
                try
                {
                    news.UpdateDate = DateTime.Now;
                    news.UpdatedBy  = User.Identity.Name;

                    //dosya yuklemesi
                    if (upload != null && upload.Length > 0 && IsExtensionValid(upload))
                    {
                        news.Photo = await UploadFileAsync(upload);
                    }


                    _context.Update(news);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NewsExists(news.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", news.CategoryId);
            return(View(news));
        }
Example #25
0
 public async Task <IActionResult> Edit(string id, ClassRoom temp)
 {
     if (id == null)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         try{
             _Context.Update(temp);
         }catch (DbUpdateConcurrencyException) {
             throw;
         }
         return(View("Index", await _Context.ClassRoomList.ToListAsync()));
     }
     return(View("Index", await _Context.ClassRoomList.ToListAsync()));
 }
Example #26
0
 public ActionResult Put(long id, [FromBody] Cuenta cuenta)
 {
     try
     {
         if (id != cuenta.Id)
         {
             return(BadRequest());
         }
         _context.Entry(cuenta).State = EntityState.Modified;
         _context.Update(cuenta);
         _context.SaveChanges();
         return(Ok(cuenta));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Example #27
0
        public async Task <IActionResult> Put(int id, [FromBody] PacientePersona PacientePersona)
        {
            try
            {
                if (id != PacientePersona.Id)
                {
                    return(NotFound());
                }
                _context.Update(PacientePersona);
                await _context.SaveChangesAsync();

                return(Ok(new { message = "La informacion fue actualizada con exito" }));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #28
0
 public ActionResult Put(int id, [FromBody] Comentario comentario)
 {
     try
     {
         if (id != comentario.Id)
         {
             return(BadRequest());
         }
         _context.Entry(comentario).State = EntityState.Modified;
         _context.Update(comentario);
         _context.SaveChanges();
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Example #29
0
        public async Task <IActionResult> Put(int id, [FromBody] Rol rol)
        {
            try
            {
                if (id != rol.idRol)
                {
                    return(NotFound());
                }

                _context.Update(rol);
                await _context.SaveChangesAsync();

                return(Ok(new { message = "Rol Actualizado" }));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
        public async Task <IActionResult> Put(int id, [FromBody] TarjetaCredito tarjeta)
        {
            try
            {
                if (id != tarjeta.Id)
                {
                    return(NotFound());
                }

                _context.Update(tarjeta);
                await _context.SaveChangesAsync();

                return(Ok(new { message = "La tarjeta fue actualizada con exito!" }));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }