Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, Branch branch)
        {
            if (id != branch.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(branch);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BranchExists(branch.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(branch));
        }
Ejemplo n.º 2
0
        public async Task <int> UpdateProduct(int productId, Product product)
        {
            var tmpPro = await GetProductById(productId);

            if (tmpPro == null)
            {
                return(0);
            }

            tmpPro.AvailableFrom  = product.AvailableFrom;
            tmpPro.AvailableUntil = product.AvailableUntil;
            tmpPro.Price          = product.Price;
            tmpPro.BorrowsDays    = (int)(product.AvailableUntil - product.AvailableFrom).TotalDays;
            tmpPro.Name           = product.Name;
            _context.Update(tmpPro);

            return(await _context.SaveChangesAsync());
        }
Ejemplo n.º 3
0
 public async Task <int> UpdateCategory(int categoryId, Category category)
 {
     _context.Update(category);
     return(await _context.SaveChangesAsync());
 }