コード例 #1
0
        public IActionResult Edit(int id)
        {
            Dealership dealership         = service.GetOneDealership(id);
            DealershipEditViewModel model = new DealershipEditViewModel
            {
                DealershipId = dealership.DealershipId,
                Name         = dealership.Name,
                Country      = dealership.Country,
                Town         = dealership.Town,
                Cars         = dealership.Cars
            };

            return(View(model));
        }
コード例 #2
0
        public void UpdateDealership(DealershipEditViewModel entity)
        {
            Dealership dealership = context.Dealerships.Find(entity.DealershipId);

            if (dealership is null)
            {
                return;
            }
            dealership.Name    = entity.Name;
            dealership.Country = entity.Country;
            dealership.Town    = entity.Town;
            dealership.Cars    = entity.Cars;

            context.Dealerships.Update(dealership);
            context.SaveChanges();
        }
コード例 #3
0
        public IActionResult Edit(DealershipEditViewModel entity)
        {
            service.UpdateDealership(entity);

            return(Redirect("/"));
        }