Пример #1
0
        /// <summary>
        /// Get all vehicle types as list of string
        /// </summary>
        /// <returns>To ajax The list of all vehicle types/BadRequest</returns>
        public ActionResult VehiclesTypesList()
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    string errorMessage = (from state in ModelState.Values
                                           from error in state.Errors
                                           select error.ErrorMessage).FirstOrDefault().ToString();
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, errorMessage));
                }

                using (VehiclesTypesLogic logic = new VehiclesTypesLogic())
                {
                    var q = logic.GetAllVehiclesTypes().Select(m => new
                    {
                        VehicleTypeID = m.VehicleTypeID,
                        DetailsString = m.VehicleTypeID + " " + m.Manufacturer + " " +
                                        m.Model + " " + m.ManufactureYear + " " +
                                        m.Transmission
                    }).ToList();

                    return(Json(q, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "We have problem on the server, Please try again later!"));
            }
        }
Пример #2
0
        //Manage Vehicles Types - for the main admin page
        public ActionResult vehiclesTypesIndex()
        {
            try
            {
                using (VehiclesTypesLogic logic = new VehiclesTypesLogic())
                {
                    return(View("VehiclesTypes", logic.GetAllVehiclesTypes()));
                }
            }
            catch (Exception)
            {
                ViewBag.Error = "We have problem on the server, Please try again later!";

                return(View("VehiclesTypes", new List <VehiclesType>()));
            }
        }