public ActionResult UpdateVehicleModel(VehicleModelModel model)
        {
            try
            {
                var vehicleService = new VehicleService(AuthenticatedUser.SessionToken);
                vehicleService.UpdateModel(model);

                var models = vehicleService.GetModels(model.VehicleMakeID);
                models.Insert(0, new VehicleModelModel()
                {
                    ID = 0, Description = "Select One"
                });

                return(Json(new { IsValid = true, Data = models.Select(f => new SelectListItem {
                        Text = f.Description, Value = f.ID.ToString()
                    }).ToList() }));
            }
            catch (GatewayException gex)
            {
                return(Json(new { IsValid = false, ErrorMessage = gex.Message }));
            }
            catch (Exception ex)
            {
                return(Json(new { IsValid = false, ErrorMessage = ex.Message }));
            }
        }
Beispiel #2
0
        private async void btnSubmit_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                var mId = cmbManufacturer.SelectedValue;
                int.TryParse(mId.ToString(), out int manufacturerId);

                var request = new VehicleModelAddUpdateRequest
                {
                    VehicleManufacturerId = manufacturerId,
                    Name = txtName.Text
                };

                VehicleModelModel modelObj = null;

                if (_vehicleModelId.HasValue && _vehicleManufacturerId.HasValue)
                {
                    modelObj = await _vehicleModelService.Update <VehicleModelModel>(_vehicleModelId.Value, request);
                }

                else
                {
                    modelObj = await _vehicleModelService.Insert <VehicleModelModel>(request);
                }

                if (modelObj != null)
                {
                    MessageBox.Show("Success!");
                    Form.ActiveForm.Close();
                }
            }
        }
Beispiel #3
0
        public void UpdateModel(VehicleModelModel model)
        {
            var request = new RestRequest("api/Vehicle/Model", Method.PUT);

            request.AddJsonBody(model);

            var response = RestClient.Execute(request);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw CreateException(response);
            }
        }
Beispiel #4
0
        public VehicleModelModel AddModel(VehicleModelModel model)
        {
            var request = new RestRequest("api/Vehicle/Model", Method.POST);

            request.AddJsonBody(model);

            var response = RestClient.Execute(request);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw CreateException(response);
            }

            return(JsonConvert.DeserializeObject <VehicleModelModel>(response.Content));
        }
 public IActionResult AddVehicleModel([FromBody] VehicleModelModel model)
 {
     try {
         if (model == null)
         {
             return(BadRequest("Body content is not valid!"));
         }
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         var entity = model.Map <VehicleModelEntity>();
         entity = _vehicleModelLogic.AddVehicleModel(entity);
         if (entity == null)
         {
             throw new Exception("Somthing went wrong while adding model to DB!");
         }
         return(Ok(entity));
     } catch (Exception e) {
         return(StatusCode(500, e));
     }
 }
Beispiel #6
0
        public VehicleModelViewModel(VehicleMakeModel vehicleMakeModel, VehicleModelService vehicleModelService, IMapper m)
        {
            vms                 = vehicleModelService;
            mapper              = m;
            vehicleMake         = vehicleMakeModel;
            vehicleModel        = AutofacHelper.GetInstance().GetContainer().Resolve <VehicleModelModel>();
            vehicleModel.MakeId = vehicleMake.Id;
            VehicleModels       = new ObservableCollection <VehicleModelModel>();
            pageIndex           = 0;
            pageSize            = 4;
            GetVehicleModel();

            CreateComand = new Command(() =>
            {
                CreateCommandFunction();
            });

            DeleteComand = new Command(() =>
            {
                DeleteCommandFunction();
            });

            UpdateCommand = new Command(() =>
            {
                UpdateCommandFunction();
            });

            NextCommand = new Command(() =>
            {
                NextCommandFunction();
            });

            PreviousCommand = new Command(() =>
            {
                PreviousCommandFunction();
            });
        }