Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,BaseInfoTargetId,MainName,NetworkInfoId,Manufacturer,Model,BaseInfoColorId,BaseInfoNatureId,Id,UserId,Status,ModDateTime,ModByUserId,Comment")] ApplicationCore.Entities.Share.Utility utility)
        {
            if (id != utility.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(utility);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UtilityExists(utility.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NetworkInfoId"] = new SelectList(_context.NetworkInfos, "Id", "HostName", utility.NetworkInfoId);
            return(View(_mapper.Map <UtilityViewModel>(utility)));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Name,BaseInfoTargetId,MainName,NetworkInfoId,Manufacturer,Model,BaseInfoColorId,BaseInfoNatureId,Id,UserId,Status,ModDateTime,ModByUserId,Comment")] ApplicationCore.Entities.Share.Utility utility)
        {
            if (ModelState.IsValid)
            {
                _context.Add(utility);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NetworkInfoId"] = new SelectList(_context.NetworkInfos, "Id", "HostName", utility.NetworkInfoId);
            return(View(_mapper.Map <UtilityViewModel>(utility)));
        }