Beispiel #1
0
        public async Task <ActionResult <ServiceTypeViewModel> > ServiceTypes(
            [FromBody] ServiceTypeInputModel serviceTypeInputModel)
        {
            ServiceType serviceType = _mapper.Map <ServiceType>(serviceTypeInputModel);

            _servicesRepository.Insert(serviceType);

            await _unitWork.SaveAsync();

            return(_mapper.Map <ServiceTypeViewModel>(serviceType));
        }
        public async Task <IActionResult> CreateServiceType(ServiceTypeInputModel model)
        {
            this.FillServiceUnifiedModel();
            if (!this.ModelState.IsValid)
            {
                return(this.View("Create", this.unifiedModel));
            }

            var serviceType = new CreateServiceTypeServiceModel
            {
                Name            = model.ServiceTypeName,
                Description     = model.ServiceTypeDescription,
                IsInDevelopment = model.IsShownInMainMenu,
            };

            await this.serviceTypesService.CreateAsync(serviceType);

            return(this.RedirectToAction("Create", this.unifiedModel));
        }
Beispiel #3
0
        public IActionResult Edit(int id)
        {
            ServiceTypeServiceModel serviceType = this.serviceTypesService.GetById(id);

            if (serviceType.Name == null)
            {
                return(this.BadRequest());
            }

            var model = new ServiceTypeInputModel
            {
                Id = serviceType.Id,
                ServiceTypeName        = serviceType.Name,
                IsShownInMainMenu      = serviceType.IsShownInMainMenu,
                ServiceTypeDescription = serviceType.Description,
            };

            return(this.View(model));
        }
Beispiel #4
0
        public async Task <IActionResult> Edit(ServiceTypeInputModel model)
        {
            if (!this.serviceTypesService.Exists(model.Id))
            {
                return(this.BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(this.RedirectToAction("Error", "Home"));
            }

            EditServiceTypeServiceModel serviceModel = new EditServiceTypeServiceModel
            {
                Id                = model.Id,
                Name              = model.ServiceTypeName,
                Description       = model.ServiceTypeDescription,
                IsShownInMainMenu = model.IsShownInMainMenu,
            };

            await this.serviceTypesService.EditAsync(serviceModel);

            return(this.RedirectToAction("Details", "ServiceTypes", new { id = serviceModel.Id }));
        }