Example #1
0
 public static void Merge(this Service entity, UpdateServiceDto dto)
 {
     entity.ServiceDescription = dto.ServiceDescription;
     entity.ServiceDate        = dto.ServiceDate;
     entity.Price   = dto.Price;
     entity.Updated = DateTime.UtcNow;
 }
Example #2
0
        public void Update(UpdateServiceDto updatedService)
        {
            _dbContext.ValidateData(updatedService);
            var service = _dbContext.Service.SingleOrDefault(o => o.ServiceID == updatedService.ServiceID);

            service.Merge(updatedService);

            _dbContext.SaveChanges();
        }
Example #3
0
        public IActionResult UpdateDetails([Required][FromBody] UpdateServiceDto updatedService)
        {
            try
            {
                _repo.Update(updatedService);

                return(Ok());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(BadRequest(ex.Message));
            }
        }
Example #4
0
        public static void ValidateData(this IHDSContext context, UpdateServiceDto dto)
        {
            var errors = new StringBuilder();

            // ServiceID
            errors.AddIfExists(dto.ServiceID.ValidateRequired(ValidationMessages.ServiceIDRequired));
            errors.AddIfExists(context.KeyExists <Service>(dto.ServiceID, ValidationMessages.ServiceIDNotFound));
            // OrderID
            errors.AddIfExists(dto.OrderID.ValidateRequired(ValidationMessages.OrderIDRequired));
            errors.AddIfExists(context.KeyExists <Order>(dto.OrderID, ValidationMessages.OrderIDNotFound));
            // ServiceDate
            errors.AddIfExists(dto.ServiceDate.ValidateFutureDate(ValidationMessages.ServiceDateValid));
            // ServiceDescription
            errors.AddIfExists(dto.ServiceDescription.ValidateRequired(ValidationMessages.ServiceDescriptionRequired));
            errors.AddIfExists(dto.ServiceDescription.ValidateLength(400, ValidationMessages.ServiceDescriptionLength));
            // Price
            errors.AddIfExists(dto.Price.ValidatePositiveDecimal(ValidationMessages.PriceRequired));

            if (errors.Length > 0)
            {
                throw new ValidationException(errors.ToString());
            }
        }
 public async Task UpdateService(UpdateServiceDto service)
 {
     throw new Exception("No function");
 }
Example #6
0
 public async Task <ServiceResponse> UpdateService(UpdateServiceDto serviceDTO)
 {
     throw new NotImplementedException();
 }
Example #7
0
 public Task <bool> UpdateServiceDto(UpdateServiceDto ServiceDto)
 {
     throw new System.NotImplementedException();
 }