示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("StoresByRouteID,StoreID,StoreName,RouteID,RouteName,UserName,CreatedDate,Order,DaysOfWeek")] StoresByRoute storesByRoute)
        {
            LoadViewBag();
            if (id != storesByRoute.StoresByRouteID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(storesByRoute);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StoresByRouteExists(storesByRoute.StoresByRouteID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(storesByRoute));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("StoresByRouteID,StoreID,StoreName,RouteID,RouteName,UserName,CreatedDate,Order,DaysOfWeek")] StoresByRoute storesByRoute)
        {
            if (ModelState.IsValid)
            {
                storesByRoute.CreatedDate = DateTime.Now;
                storesByRoute.UserName    = User.Identity.Name;
                _context.Add(storesByRoute);
                await _context.SaveChangesAsync();

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