Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Department department)
        {
            if (id != department.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(department);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentExists(department.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Phone,GenderId,CityId,RegionId,LastPurchase,ClassificationId,UserId")] Customer customer)
        {
            if (id != customer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
Beispiel #3
0
        public async Task UpdateAsync(Seller obj)
        { //se existe algum any dado no bd
            bool hasAny = await _context.Seller.AnyAsync(x => x.Id == obj.Id);

            if (!hasAny)
            {
                throw new NotFoundException("Sorry,Seller Id not found!");
            }
            try
            {
                _context.Update(obj);
                await _context.SaveChangesAsync();
            }catch (DbUpdateConcurrencyException e) {
                throw new DbConcurrencyException(e.Message);
            }
        }
Beispiel #4
0
        public async Task UpdateAsync(Seller obj)
        {
            bool hasAny = await _context.Seller.AnyAsync(x => x.ID == obj.ID);

            if (!hasAny)
            {
                throw new NotFoundException("ID not found");
            }
            try
            {
                _context.Update(obj);
                await _context.SaveChangesAsync();
            }
            catch (DbConcurrencyException e)
            {
                throw new DbConcurrencyException(e.Message);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Update seller
        /// </summary>
        /// <param name="seller">Seller</param>
        public async Task UpdateAsync(Seller seller)
        {
            bool has = await _context.Seller.AnyAsync(s => s.Id == seller.Id);

            if (!has)
            {
                throw new NotFoundException($"Seller not found!");
            }

            try
            {
                _context.Update(seller);
                await _context.SaveChangesAsync();
            }
            catch (DbConcurrencyException ex)
            {
                throw new DbConcurrencyException(ex.Message);
            }
        }
Beispiel #6
0
        public async Task UpdateAsync(Seller slr)
        {
            bool hasAny = await _context.Seller.AnyAsync(x => x.Id == slr.Id);

            if (!hasAny)
            {
                throw new NotFoundException("Seller: " + slr.Name + " Id: " + slr.Id + " was not found in database!");
            }
            try
            {
                _context.Update(slr);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                string msg = ex.Message;
                if (ex.InnerException != null)
                {
                    msg = "";
                    msg = ex.Message + "\n" + ex.InnerException.Message;
                }
                throw new DbConcurrencyException(msg);
            }
        }