示例#1
0
        public void EditarServico(ObterServicoViewModel model)
        {
            TB_SERVICOS servico = context.TB_SERVICOS.Single(x => x.Id == model.IdServico);

            if (servico == null)
            {
                throw new Exception(ExceptionMessages.EditarServicoNaoExistente);
            }

            servico.DS_SERVICO  = model.Descricao;
            servico.QT_SESSOES  = model.TotalSecoes;
            servico.BT_MASSAGEM = model.EhMassagem;
            servico.TP_MINUTOS  = model.Duracao;

            context.SaveChanges();
        }
 public ActionResult Editar(ObterServicoViewModel model)
 {
     if (!ModelState.IsValid)
     {
         Callback(new Exception(ExceptionMessages.DadosInvalidos));
     }
     else
     {
         try
         {
             servicoService.EditarServico(model);
             Callback();
         }
         catch (Exception ex)
         {
             Callback(ex);
         }
     }
     return(RedirectToAction("Index"));
 }