Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ConditionId,Condition")] TireCondition tireCondition)
        {
            if (IsTireConditionExistForAdd(tireCondition.Condition))
            {
                ModelState.AddModelError("Condition", "The tire condition is already exist");
            }
            if (ModelState.IsValid)
            {
                _context.Add(tireCondition);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tireCondition));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("TypeId,TypeName")] VehicleType vehicleType)
        {
            if (IsTypeNameExistForAdd(vehicleType.TypeName))
            {
                ModelState.AddModelError("TypeName", "The vehicle type is already exist.");
            }
            if (ModelState.IsValid)
            {
                _context.Add(vehicleType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
                //  return RedirectToAction("Create", "Vehicles");
            }
            return(View(vehicleType));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Vid,TypeId,FuelLevel,Idnumber,ConditionId,TireQty")] Vehicle vehicle)
        {
            if (IsVehicleExistforAdd(vehicle.Idnumber))
            {
                ModelState.AddModelError("Idnumber", "VIN/HIN already exists.");
            }
            if (ModelState.IsValid)
            {
                _context.Add(vehicle);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["ConditionId"] = new SelectList(_context.TireCondition, "ConditionId", "Condition", vehicle.ConditionId);
            ViewData["TypeId"]      = new SelectList(_context.VehicleType, "TypeId", "TypeName", vehicle.TypeId);
            return(View(vehicle));
        }