private void LocalValidations(FacilityRequestDTO dto)
 {
     dto.Id.ValidateString("El FID es necesario");
     dto.EOID.ValidateString("El EOID es necesario");
     dto.Name.ValidateString("El nombre del EO es necesario");
     dto.Address.ValidateString("La dirección es necesaria");
     dto.ZipCode.ValidateString("El código postal es necesario");
     dto.City.ValidateString("La ciudad es necesaria");
     dto.Country.ValidateString("El país es necesario");
     dto.ActiveFrom.ValidateObject("La fecha es necesaria");
 }
        public async Task <string> Handle(SubmitFacilityCommand request, CancellationToken cancellationToken)
        {
            FacilityRequestDTO dto = request.Request;

            try
            {
                dto.ValidateObject("La request no puede ser null");
                LocalValidations(dto);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            var facility = new Facilities();

            try
            {
                facility = new Facilities
                {
                    Id          = dto.Id,
                    EOID        = dto.EOID,
                    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 la Facility");
            }

            try
            {
                var added = _facilitiesRepository.Add(facility).Result;
                return(added);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 3
0
 public SubmitFacilityCommand(FacilityRequestDTO dto, string requestSerialized, string requestObjectName) : base(requestObjectName)
 {
     Request           = dto;
     RequestSerialized = requestSerialized;
 }