public async Task CreateAsync(CreateServiceInputModel serviceModel) { var service = new Service { Name = serviceModel.Name, Price = serviceModel.Price, }; await this.servicesRepository.AddAsync(service); await this.servicesRepository.SaveChangesAsync(); }
public async Task <IActionResult> Create(CreateServiceInputModel input) { if (!this.categoriesService.CategoryExists(input.ParentCategoryId)) { return(this.NotFound()); } var serviceModel = input.To <ServiceServiceModel>(); var imageUrl = await this.cloudinaryService.UploadAsync(input.Image); serviceModel.ImageUrl = imageUrl; await this.servicesService.CreateAsync(serviceModel); return(this.Redirect("/")); }
public ResponseWrapper <CreateServiceModel> CreateService(CreateServiceInputModel model) { var newEntity = new Service { Name = model.Name, PluralName = model.PluralName, ApplicationId = model.ApplicationId, }; context .Services .Add(newEntity); context.SaveChanges(); var response = new CreateServiceModel { ServiceId = newEntity.ServiceId, Name = newEntity.Name, PluralName = newEntity.PluralName, ApplicationId = newEntity.ApplicationId, }; return(new ResponseWrapper <CreateServiceModel>(_validationDictionary, response)); }
public dynamic CreateService([FromBody] CreateServiceInputModel model) { var orchestrator = new ServiceOrchestrator(new ModelStateWrapper(this.ModelState)); return(orchestrator.CreateService(model).GetResponse()); }