void IEtapaService.Update(FunilEtapa etapa) { etapa.UsuarioAlteracaoId = int.Parse(_httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier)); _funilEtapaRep.Edit(etapa); _unitOfWork.Commit(); }
public IActionResult Put(FunilViewModel funilViewModel, int Id) { for (int i = 0; i < funilViewModel.Etapas.Count; i++) { if (funilViewModel.Etapas[i].Id == 0 && funilViewModel.Etapas[i].FunilId == 0) { var funilEtapa = new FunilEtapa() { FunilId = funilViewModel.Id, Nome = funilViewModel.Etapas[i].Nome, Ordem = short.Parse(funilViewModel.Etapas[i].Ordem.ToString()) }; _etapaService.Create(funilEtapa); funilViewModel.Etapas[i].Id = funilEtapa.Id; funilViewModel.Etapas[i].FunilId = funilViewModel.Id; } else { var etapa = _mapper.Map <EtapaViewModel, FunilEtapa>(funilViewModel.Etapas[i]); _etapaService.Update(etapa); } } var funil = _mapper.Map <FunilViewModel, Funil>(funilViewModel); try { _funilService.Update(funil); return(Ok()); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }
FunilEtapa IEtapaService.Create(FunilEtapa etapa) { //if (_funilEtapaRep.FindBy(x => x.Nome == etapa.Nome).Any()) //{ // throw new Infrastructure.Services.Core.AppException("Nome \"" + etapa.Nome + "\" já existe."); //} etapa.UsuarioCriacaoId = int.Parse(_httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier)); _funilEtapaRep.Add(etapa); _unitOfWork.Commit(); return(etapa); }