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; }
public void Update(UpdateServiceDto updatedService) { _dbContext.ValidateData(updatedService); var service = _dbContext.Service.SingleOrDefault(o => o.ServiceID == updatedService.ServiceID); service.Merge(updatedService); _dbContext.SaveChanges(); }
public IActionResult UpdateDetails([Required][FromBody] UpdateServiceDto updatedService) { try { _repo.Update(updatedService); return(Ok()); } catch (Exception ex) { _logger.LogError(ex.Message); return(BadRequest(ex.Message)); } }
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"); }
public async Task <ServiceResponse> UpdateService(UpdateServiceDto serviceDTO) { throw new NotImplementedException(); }
public Task <bool> UpdateServiceDto(UpdateServiceDto ServiceDto) { throw new System.NotImplementedException(); }