Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ItemId,ShelfId,ItemPatternId,NotificationId,HowMuchLeft,ExpirationDate,IsOpen")] Item item)
        {
            if (id != item.ItemId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(item);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemExists(item.ItemId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ItemPatternId"]  = new SelectList(_context.Itempattern, "ItemPatternId", "ItemPatternId", item.ItemPatternId);
            ViewData["NotificationId"] = new SelectList(_context.Notificationtype, "NotificationId", "Type", item.NotificationId);
            ViewData["ShelfId"]        = new SelectList(_context.Shelf, "ShelfId", "Name", item.ShelfId);
            return(View(item));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("CategoryItemPatternId,StorageId,NotificationId,Name,Type,CurrentQuantity,ExpectedQuantity,ShopingFrequency")] Categoryitempattern categoryitempattern)
        {
            if (id != categoryitempattern.CategoryItemPatternId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categoryitempattern);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryitempatternExists(categoryitempattern.CategoryItemPatternId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NotificationId"] = new SelectList(_context.Notificationtype, "NotificationId", "Type", categoryitempattern.NotificationId);
            ViewData["StorageId"]      = new SelectList(_context.Storage, "StorageId", "Name", categoryitempattern.StorageId);
            return(View(categoryitempattern));
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, [Bind("UserId,Name,Login,Password,Email")] User user)
        {
            if (id != user.UserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                db.Update(user);
                await db.SaveChangesAsync();

                return(RedirectToAction(nameof(Edit)));
            }
            return(View(user));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ItemPatternId,CategoryItemPatternId,BarCode,Unit,Size,Name,PhotoName,SeverityLevel,Capacity,LongLife")] Itempattern itempattern, IFormFile photoName)
        {
            if (id != itempattern.ItemPatternId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (photoName == null)
                    {
                        return(RedirectToAction(nameof(Index)));
                    }
                    else
                    {
                        /*var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/images", photoName.FileName);
                         * var stream = new FileStream(path, FileMode.Create);
                         * await photoName.CopyToAsync(stream);*/
                        itempattern.PhotoName = Path.GetFileName(photoName.FileName);
                    }

                    _context.Update(itempattern);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItempatternExists(itempattern.ItemPatternId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryItemPatternId"] = new SelectList(_context.Categoryitempattern, "CategoryItemPatternId", "Name", itempattern.CategoryItemPatternId);
            return(View(itempattern));
        }