public ActionResult AddNewCar(AddNewCar addcar, HttpPostedFileBase car_photo)
        {
            if (ModelState.IsValid)
            {
                if (car_photo != null)
                {
                    FileUpload.DeleteFile(addcar.Photo);
                    addcar.Photo = FileUpload.UploadFile(car_photo);
                }

                Auto auto = new Auto();
                addcar.AssignTo(auto);

                AutoAPI.AddAuto(auto);

                return RedirectToAction("ActionAddCarSuccess", "Administration");
            }
            return RedirectToAction("ActionAddCarSuccess", "Administration");
        }
        public ActionResult AddNewCar(Auto aut)
        {
            IList<ModelCar> ModelList = ModelCarAPI.GetModels();

            IEnumerable<SelectListItem> selectList =
                from c in ModelList
                select new SelectListItem
                {
                    Text = c.ModelAuto,
                    Value = c.ID.ToString("b"),
                    Selected = (c.ID == aut.ModelID)

                };
            ViewData["TestList2"] = selectList;

            var model = new AddNewCar();
            model.ModelTypeOptions = selectList;
            return View(model);
        }
Пример #3
0
        public static AddNewCar FromDomainModel(Auto auto)
        {
            if (auto == null)
                return null;

            return new AddNewCar()
            {
                Advance = auto.Advance,
                Body = auto.BodyType,
                Status = auto.Status,
                Photo = auto.PhotoFileName,
                Name = auto.Name,
                ModelID = auto.ModelID.ToString(),
                KMRate = auto.KmRate,
                CarColor = auto.CarColor,
                CarNumber = auto.CarNumber,
                CurrentMilage = auto.CurrentMilage,
                DayRate = auto.DayRate,
                Engine = auto.Engine,
                InsuranceNumber = auto.InsuranceNumber,
                CreationYear = auto.CreationYear

                ///TODO
            };
        }
Пример #4
0
        public static SearchCar FromDomainModel(Auto auto)
        {
            if (auto == null)
                return null;

            return new SearchCar()
            {

                ///TODO
            };
        }