Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("CashDeskId,UtilityId,Id,UserId,Status,ModDateTime,ModByUserId,Comment")] CashDeskUtility cashDeskUtility)
        {
            if (id != cashDeskUtility.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cashDeskUtility);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CashDeskUtilityExists(cashDeskUtility.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CashDeskId"] = new SelectList(_context.CashDesks, "Id", "Name", cashDeskUtility.CashDeskId);
            ViewData["UtilityId"]  = new SelectList(_context.Utilities, "Id", "MainName", cashDeskUtility.UtilityId);
            return(View(_mapper.Map <CashDeskUtilityViewModel>(cashDeskUtility)));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("CashDeskId,UtilityId,Id,UserId,Status,ModDateTime,ModByUserId,Comment")] CashDeskUtility cashDeskUtility)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cashDeskUtility);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CashDeskId"] = new SelectList(_context.CashDesks, "Id", "Name", cashDeskUtility.CashDeskId);
            ViewData["UtilityId"]  = new SelectList(_context.Utilities, "Id", "MainName", cashDeskUtility.UtilityId);
            return(View(_mapper.Map <CashDeskUtilityViewModel>(cashDeskUtility)));
        }