示例#1
0
        public async Task CreateAsync(ServiceServiceModel input)
        {
            var service = input.To <Service>();

            await this.serviceRepository.AddAsync(service);

            await this.serviceRepository.SaveChangesAsync();
        }
示例#2
0
        public async Task UpdateAsync(ServiceServiceModel input)
        {
            var service = await this.serviceRepository
                          .GetByIdAsync(input.Id);

            service.Name        = input.Name;
            service.CategoryId  = input.CategoryId;
            service.Description = input.Description;
            service.Price       = input.Price;
            service.ImageUrl    = input.ImageUrl;

            this.serviceRepository.Update(service);
            await this.serviceRepository.SaveChangesAsync();
        }
        public IActionResult Edit(int id)
        {
            ServiceServiceModel service = this.servicesService.GetById(id);

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

            var model = new ServiceInputModel
            {
                Id                 = service.Id,
                ServiceName        = service.Name,
                IsShownInSubMenu   = service.IsShownInSubMenu,
                ServiceDescription = service.Description,
                Price              = service.Price,

                VehicleTypeId = service.VehicleTypeId,
                VehicleTypes  = this.vehicleTypesService.GetAll().Select(x => new VehicleTypesDropdownViewModel
                {
                    Id       = x.Id,
                    Name     = x.Name,
                    Category = x.Category,
                }),

                ServiceTypeId = service.ServiceTypeId,
                ServiceTypes  = this.serviceTypesService.GetAll().Select(x => new ServiceTypesDropdownViewModel
                {
                    Id   = x.Id,
                    Name = x.Name,
                }),

                OperatingLocationIds = service.OperatingLocationIds,
                OperatingLocations   = this.operatingLocationsService.GetAll().Select(x => new OperatingLocationsDropdownViewModel
                {
                    Id      = x.Id,
                    Town    = x.Town,
                    Address = x.Address,
                }),

                DocumentIds = service.DocumentIds,
                Documents   = this.documentsService.GetAll().Select(x => new DocumentsDropdownViewModel
                {
                    Id   = x.Id,
                    Name = x.Name,
                }),
            };

            return(this.View(model));
        }
        public IActionResult Delete(int id)
        {
            ServiceServiceModel service = this.servicesService.GetById(id);

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

            var model = new DeleteServiceViewModel
            {
                Id               = service.Id,
                Name             = service.Name,
                Price            = service.Price,
                Description      = service.Description,
                ServiceType      = service.ServiceType,
                VehicleType      = service.VehicleType,
                IsShownInSubMenu = (service.IsShownInSubMenu == true) ? "Да" : "Не",
                //TODO: add operating locations and documents tables
            };

            return(this.View(model));
        }
        public IActionResult Details(int id)
        {
            ServiceServiceModel service = this.servicesService.GetById(id);

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

            var model = new ServiceDetailsViewModel
            {
                Id               = service.Id,
                Name             = service.Name,
                IsShownInSubMenu = service.IsShownInSubMenu == true ? "Да" : "Не",
                ServiceType      = service.ServiceType,
                VehicleType      = service.VehicleType,
                Description      = service.Description,
                Price            = service.Price,
                //TODO: Add operatingLocations, documents, reservations
            };

            return(this.View(model));
        }