Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("PaperWeightID,Grammature,Description,IsActive,AddedDate,UpdatedDate,AddedUserID,UpdatedUserID")] PaperWeight paperWeight)
        {
            if (id != paperWeight.PaperWeightID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    paperWeight.UpdatedDate   = DateTime.Now;
                    paperWeight.UpdatedUserID = Int32.Parse(HttpContext.Session.GetString("UserID"));
                    _context.Update(paperWeight);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaperWeightExists(paperWeight.PaperWeightID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AddedUserID"]   = new SelectList(_context.Users, "UserID", "Login", paperWeight.AddedUserID);
            ViewData["UpdatedUserID"] = new SelectList(_context.Users, "UserID", "Login", paperWeight.UpdatedUserID);
            return(View(paperWeight));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("PaperWeightID,Grammature,Description,IsActive,AddedDate,UpdatedDate,AddedUserID,UpdatedUserID")] PaperWeight paperWeight)
        {
            if (ModelState.IsValid)
            {
                paperWeight.IsActive    = true;
                paperWeight.AddedDate   = DateTime.Now;
                paperWeight.AddedUserID = Int32.Parse(HttpContext.Session.GetString("UserID"));
                _context.Add(paperWeight);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AddedUserID"]   = new SelectList(_context.Users, "UserID", "Login", paperWeight.AddedUserID);
            ViewData["UpdatedUserID"] = new SelectList(_context.Users, "UserID", "Login", paperWeight.UpdatedUserID);
            return(View(paperWeight));
        }
 public void Awake()
 {
     instance = this;
 }