示例#1
0
        public ActionResult DeleteConfirmed(int id)
        {
            ClienteSet clienteSet = clienteRepository.ObterPorId(id);

            clienteRepository.Apagar(clienteSet);
            return(RedirectToAction("Index"));
        }
示例#2
0
 public void Inserir(ClienteSet entity)
 {
     if (entity != null)
     {
         dbcontext.ClienteSet.Add(entity);
         dbcontext.Entry(entity).State = System.Data.Entity.EntityState.Added;
         dbcontext.SaveChanges();
     }
 }
示例#3
0
        // 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));
        }
示例#4
0
 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);
     }
 }
示例#5
0
 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);
     }
 }
示例#6
0
        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));
        }