public ActionResult DeleteConfirmed(int id) { ClienteSet clienteSet = clienteRepository.ObterPorId(id); clienteRepository.Apagar(clienteSet); return(RedirectToAction("Index")); }
public void Inserir(ClienteSet entity) { if (entity != null) { dbcontext.ClienteSet.Add(entity); dbcontext.Entry(entity).State = System.Data.Entity.EntityState.Added; dbcontext.SaveChanges(); } }
// GET: Cliente/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ClienteSet clienteSet = clienteRepository.ObterPorId(id.Value); if (clienteSet == null) { return(HttpNotFound()); } return(View(clienteSet)); }
public void Atualizar(ClienteSet entity) { try { if (entity != null) { dbcontext.ClienteSet.Add(entity); dbcontext.Entry(entity).State = System.Data.Entity.EntityState.Modified; dbcontext.SaveChanges(); } } catch (Exception ex) { logger.Error(ex); } }
public void Apagar(ClienteSet entity) { try { if (entity != null) { dbcontext.ClienteSet.Remove(entity); dbcontext.Entry(entity).State = System.Data.Entity.EntityState.Deleted; dbcontext.SaveChanges(); } } catch (Exception ex) { logger.Error(ex); } }
public ActionResult Create([Bind(Include = "Id,Nome,Sobrenone,CPF,DataNascimento,DataCadastro,Ativo")] ClienteSet clienteSet) { if (clienteRepository.ObterPorCpf(clienteSet.CPF) != null) { ModelState.AddModelError("CPF", "Já existe um cliente com o mesmo CPF no sistema."); } clienteSet.UsuarioId = usuarioRepository.ObterPorLogin(FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name).Id; if (ModelState.IsValid) { clienteRepository.Inserir(clienteSet); return(RedirectToAction("Index")); } return(View(clienteSet)); }