コード例 #1
0
        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();
        }
コード例 #2
0
        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("/"));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        public dynamic CreateService([FromBody] CreateServiceInputModel model)
        {
            var orchestrator = new ServiceOrchestrator(new ModelStateWrapper(this.ModelState));

            return(orchestrator.CreateService(model).GetResponse());
        }