示例#1
0
        public IActionResult Create([Bind("BrandID,BrandName," +
                                          "BrandCompany,BrandCountry,BrandStartDate,BrandEndingDate," +
                                          "BrandCharacteristic,BrandCategory,BrandDescription")] Brand brand)
        {
            if (ModelState.IsValid)
            {
                if (BrandExists(brand.BrandID))
                {
                    return(View("Message", "Уже существует марка автомобиля с данным идентификатором!"));
                }
                _db.Add(brand);
                _db.SaveChanges();
                return(RedirectToAction("Brands"));
            }

            return(View(brand));
        }
示例#2
0
        public IActionResult Create([Bind("OwnerID,OwnerName,OwnerBirthDate,OwnerAddress," +
                                          "OwnerPassport,OwnerNumberOfDriverLicense,OwnerLicenseDeliveryDate,OwnerLicenseValidityDate," +
                                          "OwnerCategory,OwnerMoreInformation")] Owner owner)
        {
            if (ModelState.IsValid)
            {
                if (OwnerExists(owner.OwnerID))
                {
                    return(View("Message", "Уже существует владелец с данным идентификатором!"));
                }
                _db.Add(owner);
                _db.SaveChanges();
                return(RedirectToAction("Owners"));
            }

            return(View(owner));
        }
示例#3
0
        public IActionResult Create([Bind("CarID,BrandID,OwnerID,CarRegistrationNumber," +
                                          "CarPhoto,CarNumberOfBody,CarNumberOfMotor,CarNumberOfPassport," +
                                          "CarReleaseDate,CarRegistrationDate," +
                                          "CarLastCheckupDate,CarColor,CarDescription")] Car car)
        {
            if (ModelState.IsValid)
            {
                if (CarExists(car.CarID))
                {
                    return(View("Message", "Уже существует автомобиль с данным идентификатором!"));
                }
                _db.Add(car);
                _db.SaveChanges();
                return(RedirectToAction("Cars"));
            }

            ViewData["BrandID"] = new SelectList(_db.Brands, "BrandID", "BrandName", car.BrandID);
            ViewData["OwnerID"] = new SelectList(_db.Owners, "OwnerID", "OwnerName", car.OwnerID);
            return(View(car));
        }