public async Task <string> Update(EconomicOperators economicOperators) { string deleted; try { deleted = await _economicOperatorService.DeleteEO(economicOperators.Id); } catch { throw new Exception("No se puede modificar el EO"); } if (deleted != "") { var result = await _context.EconomicOperators.AddAsync(economicOperators); await _context.SaveChangesAsync(); return(result.Entity.Id); } else { throw new Exception("Error actualizando el EO"); } }
public async Task <string> Handle(UpdateEOCommand request, CancellationToken cancellationToken) { EORequestDTO dto = request.Request; try { dto.ValidateObject("La request no puede ser null"); LocalValidations(dto); } catch (Exception ex) { throw new Exception(ex.Message); } var eo = new EconomicOperators(); try { eo = new EconomicOperators { Id = dto.Id, Name = dto.Name, Description = dto.Description, Address = dto.Address, ZipCode = dto.ZipCode, City = dto.City, Country = dto.Country, ActiveFrom = dto.ActiveFrom }; } catch { throw new Exception("Error al formatear el EO"); } try { var added = _eoRepository.Add(eo).Result; return(added); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <string> Add(EconomicOperators economicOperators) { var exist = await _economicOperatorService.GetEOById(economicOperators.Id); if (exist == null) { try { var result = await _context.EconomicOperators.AddAsync(economicOperators); await _context.SaveChangesAsync(); return(result.Entity.Id); } catch { throw new Exception("Error creando el EO"); } } else { throw new Exception("Ya existe este EO"); } }