예제 #1
0
 public Boolean Delete(VehicleModel vehicleModel)
 {
     if (vehicleModel == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     vehicleModelService.DeleteVehicleModel(vehicleModel.VehicleModelId);
     return(true);
 }
예제 #2
0
 public BaseViewModel(IVehicleMakeService iVehicleMakeService, IVehicleModelService iVehicleModelService)
 {
     this.iVehicleMakeService  = iVehicleMakeService;
     this.iVehicleModelService = iVehicleModelService;
     MessagingCenter.Subscribe <VehicleMakeViewModel, string>(this, "Delete", async(s, arg) =>
     {
         await iVehicleModelService.DeleteVehicleModel(arg, 0, true);
     });
 }
예제 #3
0
        public async Task <HttpResponseMessage> DeleteVehicleModel(Guid id)
        {
            var vehicleModel = Mapper.Map <VehicleModelViewModel>(await _vehicleModelService.GetIdVehicleModel(id));

            if (vehicleModel == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "vehicle model not found"));
            }

            var removeVehicleModel = await _vehicleModelService.DeleteVehicleModel(Mapper.Map <VehicleModelDomainModel>(vehicleModel));

            return(Request.CreateResponse(HttpStatusCode.OK, removeVehicleModel));
        }
예제 #4
0
        public async Task <ActionResult <VehicleModel> > DeleteModel(Guid id)
        {
            var vehicleModelToDelete = await service.DeleteVehicleModel(id);

            if (vehicleModelToDelete == null)
            {
                return(NotFound("Vehicle model not found."));
            }

            var deletedVehicleMakeRestModel = mapper.Map <ReadVehicleModel>(vehicleModelToDelete);

            return(Ok(deletedVehicleMakeRestModel));
        }
        public async Task <IHttpActionResult> DeleteVehicleModel(int id)
        {
            IVehicleModel vehicleModel = await _vehicleService.FindVehicleModel(id);

            if (vehicleModel == null)
            {
                return(NotFound());
            }

            await _vehicleService.DeleteVehicleModel(id);

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            try
            {
                VehicleModel vehicleModel = await _vehicleService.FindVehicleModel(id);

                await _vehicleService.DeleteVehicleModel(vehicleModel);
            }
            catch (DataException)
            {
                return(RedirectToAction("Delete", new { id, saveChangesError = true }));
            }
            return(RedirectToAction("Index"));
        }
        public async Task <IHttpActionResult> DeleteVehicleModel(int id)
        {
            if (id <= 0)
            {
                return(BadRequest("Not a valid student id"));
            }

            IVehicleModel vehicleModel = await _vehicleModelService.GetVehicleModelByIDAsync(id);



            if (vehicleModel == null)
            {
                return(NotFound());
            }

            await _vehicleModelService.DeleteVehicleModel(id);

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #8
0
 public ActionResult Delete(int id)
 {
     _vehicleModelService.DeleteVehicleModel(id);
     _vehicleModelService.SaveVehicleModel();
     return(RedirectToAction("Index"));
 }