public async Task <IActionResult> Edit(EditServiceInputModel input)
        {
            if (
                !this.categoriesService.CategoryExists(input.CategoryId) ||
                !this.servicesService.CheckIfServiceExists(input.Id))
            {
                return(this.NotFound());
            }

            var serviceDto = input.To <ServiceServiceModel>();

            await this.servicesService.UpdateAsync(serviceDto);

            return(this.RedirectToAction("Details", "Categories", new { id = input.CategoryId }));
        }
Exemple #2
0
        public ResponseWrapper <EditServiceModel> EditService(int serviceId, EditServiceInputModel model)
        {
            var entity = context
                         .Services
                         .Single(x =>
                                 x.ServiceId == serviceId
                                 );

            entity.Name          = model.Name;
            entity.PluralName    = model.PluralName;
            entity.ApplicationId = model.ApplicationId;
            context.SaveChanges();
            var response = new EditServiceModel
            {
                ServiceId     = entity.ServiceId,
                Name          = entity.Name,
                PluralName    = entity.PluralName,
                ApplicationId = entity.ApplicationId,
            };

            return(new ResponseWrapper <EditServiceModel>(_validationDictionary, response));
        }
        public dynamic EditService(int serviceId, [FromBody] EditServiceInputModel model)
        {
            var orchestrator = new ServiceOrchestrator(new ModelStateWrapper(this.ModelState));

            return(orchestrator.EditService(serviceId, model).GetResponse());
        }