public async Task <ActionResult <CarWashShortModel> > AddCarWash([FromBody] CarWashFullModel model) => await Exec(async operation => { var(_, id) = VerifyUser(UserRole.Company); if (!ModelState.IsValid) { throw new Exception(ExceptionMessage.ModelIsInvalid); } var carWash = await companyProfileService.AddCarWash(operation, id, model.ToEntity()); return(new CarWashShortModel().ToModel(carWash)); });
public async Task <ActionResult <CarWashFullModel> > GetCarWash(int carWashId, [FromQuery(Name = "s")] bool isServicesNeeded) => await Exec(async operation => { VerifyUser(UserRole.Company); var entity = await companyProfileService.GetCarWashById(operation, carWashId); var model = new CarWashFullModel().ToModel(entity); if (isServicesNeeded) { var services = await companyProfileService.GetCarWashServiceListByCarWash(operation, carWashId); model.Services = services.Select(item => new CarWashServiceModel().ToModel(item)).ToList(); } return(model); });