コード例 #1
0
        public ActionResult Edit(EditVm model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            RentACarRepository repo = new RentACarRepository();

            RentACar item = new RentACar();

            item.Id          = model.Id;
            item.CarId       = model.CarId;
            item.PricePerDay = model.PricePerDay;
            item.Status      = model.Status;

            if (item.Id > 0)
            {
                repo.Update(item);
            }
            else
            {
                repo.Insert(item);
            }

            return(RedirectToAction("Index", "RentACar"));
        }
コード例 #2
0
        public ActionResult Delete(int id)
        {
            RentACarRepository repo = new RentACarRepository();

            repo.Delete(id);

            return(RedirectToAction("Index", "RentACar"));
        }
コード例 #3
0
        public ActionResult Index()
        {
            RentACarRepository repo  = new RentACarRepository();
            List <RentACar>    items = repo.GetAll();

            ViewData["rentacar"] = items;
            return(View());
        }
コード例 #4
0
        public ActionResult Edit(int?id)
        {
            RentACarRepository repo = new RentACarRepository();
            RentACar           item = id == null ? new RentACar() : repo.GetById(id.Value);

            EditVm model = new EditVm();

            model.Id          = item.Id;
            model.CarId       = item.CarId;
            model.PricePerDay = item.PricePerDay;
            model.Status      = item.Status;

            return(View(model));
        }
コード例 #5
0
 public RentACarService(RentACarRepository rentACarRepository)
 {
     _rentACarRepository = rentACarRepository;
 }
コード例 #6
0
 public VehicleService(VehicleRepository repository, RentACarRepository companyRepository)
 {
     _repository        = repository;
     _companyRepository = companyRepository;
 }