Beispiel #1
0
        public async Task <IHttpActionResult> Post(VehicleTypeInputModel model)
        {
            if (model == null)
            {
                return(BadRequest(ErrorMessage.Type.RequiredTypeInputModel));
            }

            if (model.Name == null)
            {
                return(BadRequest(ErrorMessage.Type.RequiredType));
            }

            VehicleType type = new VehicleType()
            {
                Id   = model.Id,
                Name = model.Name,
                VehicleTypeGroupId = model.VehicleTypeGroupId
            };

            CommentsStagingModel comment = new CommentsStagingModel()
            {
                Comment = model.Comment
            };

            var attachments = SetUpAttachmentsModels(model.Attachments);

            var changeRequestId = await _vehicleTypeApplicationService.AddAsync(type, CurrentUser.Email, comment, attachments);

            return(Ok(changeRequestId));
        }
Beispiel #2
0
        public async Task <IHttpActionResult> Put(int id, VehicleTypeInputModel m)
        {
            if (m == null)
            {
                return(BadRequest(ErrorMessage.Type.RequiredTypeInputModel));
            }

            if (m.Name == null)
            {
                return(BadRequest(ErrorMessage.Type.RequiredType));
            }

            VehicleType type = new VehicleType()
            {
                Id   = m.Id,
                Name = m.Name,
                VehicleTypeGroupId = m.VehicleTypeGroupId,
                VehicleCount       = m.VehicleCount,
                BaseVehicleCount   = m.BaseVehicleCount,
                ModelCount         = m.ModelCount
            };

            CommentsStagingModel comment = new CommentsStagingModel()
            {
                Comment = m.Comment
            };

            var attachments = SetUpAttachmentsModels(m.Attachments);

            var changeRequestId = await _vehicleTypeApplicationService.UpdateAsync(type, id, CurrentUser.Email, comment, attachments);

            return(Ok(changeRequestId));
        }
Beispiel #3
0
        public async Task <IHttpActionResult> Delete(int id, VehicleTypeInputModel vehicleInputModel)
        {
            CommentsStagingModel comment = new CommentsStagingModel()
            {
                Comment = vehicleInputModel.Comment
            };

            var attachments = SetUpAttachmentsModels(vehicleInputModel.Attachments);

            var changeRequestId = await _vehicleTypeApplicationService.DeleteAsync(null, id, CurrentUser.Email, comment, attachments);

            return(Ok(changeRequestId));
        }
        public async Task <IActionResult> CreateVehicleType(VehicleTypeInputModel model)
        {
            this.FillServiceUnifiedModel();
            if (!this.ModelState.IsValid)
            {
                return(this.View("Create", this.unifiedModel));
            }

            var vehicleType = new CreateVehicleTypeServiceModel
            {
                Name = model.VehicleTypeName,
                VehicleCategoryId = model.VehicleCategoryId,
                Description       = model.VehicleTypeDescription,
            };

            await this.vehicleTypesService.CreateAsync(vehicleType);

            return(this.RedirectToAction("Create"));
        }
        public IActionResult Edit(int id)
        {
            VehicleTypeServiceModel vehicleType = this.vehicleTypesService.GetById(id);

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

            var model = new VehicleTypeInputModel
            {
                Id = vehicleType.Id,
                VehicleTypeName        = vehicleType.Name,
                VehicleTypeDescription = vehicleType.Description,
                VehicleCategoryId      = vehicleType.VehicleCategoryId,
            };

            return(this.View(model));
        }
        public async Task <IActionResult> Edit(VehicleTypeInputModel model)
        {
            if (!this.vehicleTypesService.Exists(model.Id))
            {
                return(this.BadRequest());
            }

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

            EditVehicleTypeServiceModel serviceModel = new EditVehicleTypeServiceModel
            {
                Id                = model.Id,
                Name              = model.VehicleTypeName,
                Description       = model.VehicleTypeDescription,
                VehicleCategoryId = model.VehicleCategoryId,
            };

            await this.vehicleTypesService.EditAsync(serviceModel);

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