コード例 #1
0
 public async Task UpdateCategoryAsync(Category category)
 {
     try
     {
         _context.Entry <Category>(category).State = EntityState.Modified;
         await _context.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         throw new Exception("An error has occurred");
     }
 }
コード例 #2
0
 public async Task UpdateBrandAsync(Brand brand)
 {
     try
     {
         _context.Entry <Brand>(brand).State = EntityState.Modified;
         await _context.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         throw new Exception("An error has occurred");
     }
 }
コード例 #3
0
        public async Task DeleteProductAync(Guid id)
        {
            try
            {
                Product obj = await _context.Products.FindAsync(id);

                _context.Entry <Product>(obj).State = EntityState.Deleted;
                await _context.SaveChangesAsync();
            }
            catch (ArgumentNullException ex)
            {
                throw new ArgumentNullException(ex.Message);
            }
        }
コード例 #4
0
        public Group Save(Group item)
        {
            try
            {
                item.Teams.ToList().ForEach(s => _context.Entry(s).State = EntityState.Modified);

                _context.Group.Add(item);
                _context.SaveChanges();
                return(item);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
コード例 #5
0
        public Payment Put([FromBody] Payment payment)
        {
            _context.Entry <Payment>(payment).State = EntityState.Modified;
            _context.SaveChanges();

            return(payment);
        }
コード例 #6
0
ファイル: ProductController.cs プロジェクト: Romaquis/BlueM
        public Product Put([FromBody] Product product)
        {
            _context.Entry <Product>(product).State = EntityState.Modified;
            _context.SaveChanges();

            return(product);
        }
コード例 #7
0
        public User Put([FromBody] User user)
        {
            _context.Entry <User>(user).State = EntityState.Modified;
            _context.SaveChanges();

            return(user);
        }
コード例 #8
0
        public Category Update(Category category)
        {
            _context.Entry <Category>(category).State = EntityState.Modified;
            _context.SaveChanges();

            return(category);
        }
コード例 #9
0
        public Match Update(Match item)
        {
            _context.Entry <Match>(item).State = EntityState.Modified;
            _context.SaveChanges();

            return(item);
        }
コード例 #10
0
        public Enrolment Put([FromBody] Enrolment enrolment)
        {
            _context.Entry <Enrolment>(enrolment).State = EntityState.Modified;
            _context.SaveChanges();

            return(enrolment);
        }
コード例 #11
0
        public LivingRoom Put([FromBody] LivingRoom livingRoom)
        {
            _context.Entry <LivingRoom>(livingRoom).State = EntityState.Modified;
            _context.SaveChanges();

            return(livingRoom);
        }
コード例 #12
0
        public Course Put([FromBody] Course course)
        {
            _context.Entry <Course>(course).State = EntityState.Modified;
            _context.SaveChanges();

            return(course);
        }
コード例 #13
0
ファイル: AccountController.cs プロジェクト: Romaquis/BlueM
        public Account Put([FromBody] Account account)
        {
            _context.Entry <Account>(account).State = EntityState.Modified;
            _context.SaveChanges();

            return(account);
        }
コード例 #14
0
        public async Task <Category> SaveCategory(Category category)
        {
            _context.Entry <Category>(category).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(category);
        }
コード例 #15
0
        public async Task <Survivor> Update(Survivor survivor)
        {
            _context.Entry <Survivor>(survivor).State = EntityState.Modified;
            _context.SaveChanges();

            return(survivor);
        }
コード例 #16
0
        public User Update(User user)
        {
            _context.Entry <User>(user).State = EntityState.Modified;
            _context.SaveChanges();

            return(user);
        }
コード例 #17
0
        public Student Put([FromBody] Student student)
        {
            _context.Entry <Student>(student).State = EntityState.Modified;
            _context.SaveChanges();

            return(student);
        }
コード例 #18
0
        public async Task <ShelterStock> Update(ShelterStock shelterStock)
        {
            _context.Entry <ShelterStock>(shelterStock).State = EntityState.Modified;
            _context.SaveChanges();

            return(shelterStock);
        }
コード例 #19
0
        public Category Put([FromBody] Category category)
        {
            _context.Entry <Category>(category).State = EntityState.Modified;
            _context.SaveChanges();

            return(category);
        }
コード例 #20
0
        public async Task <Resource> Update(Resource resource)
        {
            _context.Entry <Resource>(resource).State = EntityState.Modified;
            _context.SaveChanges();

            return(resource);
        }
コード例 #21
0
        public ResultViewModel Put([FromBody] EditProductViewModel model)
        {
            model.Validate();
            if (model.Invalid)
            {
                return new ResultViewModel
                       {
                           Success = false,
                           Message = "Não foi possível alterar o produto!",
                           Data    = model.Notifications
                       }
            }
            ;
            Product product = _context.Products.Find(model.Id);

            product.Title          = model.Title;
            product.CategoryId     = model.CategoryId;
            product.Descriptions   = model.Description;
            product.Image          = model.Image;
            product.LastUpdateDate = DateTime.Now;
            product.Price          = model.Price;
            product.Quantity       = model.Quantity;
            _context.Entry <Product>(product).State = EntityState.Modified;
            _context.SaveChanges();
            return(new ResultViewModel
            {
                Success = true,
                Message = "Produto alterado com sucesso!",
                Data = product
            });
        }
    }
コード例 #22
0
        public Subscription Put([FromBody] Subscription subscription)
        {
            _context.Entry <Subscription>(subscription).State = EntityState.Modified;
            _context.SaveChanges();

            return(subscription);
        }
コード例 #23
0
        public Card Put([FromBody] Card card)
        {
            _context.Entry <Card>(card).State = EntityState.Modified;
            _context.SaveChanges();

            return(card);
        }
コード例 #24
0
        public Product Update(Product product)
        {
            _context.Entry <Product>(product).State = EntityState.Modified;
            _context.SaveChanges();

            return(product);
        }
コード例 #25
0
        public Category Put([FromBody] Category category)
        {
            //QUando usamos o entitystate.modified ele faz o update no destino na minha modelo
            _context.Entry <Category>(category).State = EntityState.Modified;
            _context.SaveChanges();

            return(category);
        }
コード例 #26
0
        public T Editar(T entity)
        {
            //Sem o Entry
            //var editar = Obter(entity.Id);
            //editar.Nome = cliente.Nome;
            //..

            _ctx.Entry(entity).State = EntityState.Modified;
            salvar();
            return(entity);
        }
コード例 #27
0
        public async Task <ActionResult> PutCategory(
            [FromServices] StoreDataContext _context,
            [FromBody] Category category)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Entry <Category>(category).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(PutCategory), category));
        }
コード例 #28
0
        public Team Update(Team item)
        {
            try
            {
                _context.Entry <Team>(item).State = EntityState.Modified;
                _context.SaveChanges();

                return(item);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
コード例 #29
0
        public async Task <bool> Put(Category category)
        {
            bool resultUpdate = false;

            try
            {
                context.Entry <Category>(category).State = EntityState.Modified;
                int resultLine = await context.SaveChangesAsync();

                resultUpdate = resultLine > 0 ? true : false;
            } catch (Exception ex)
            {
                Console.WriteLine("Put -> " + ex.Message);
            }
            return(resultUpdate);
        }
コード例 #30
0
        public virtual async Task UpdateAsync(T entity)
        {
            using (StoreDataContext dataContext = new StoreDataContext())
            {
                try
                {
                    entity.ModifyDateTime = DateTime.Now;

                    dataContext.Entry(entity).State = EntityState.Modified;
                    dataContext.SaveChanges();
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    var entry = ex.Entries.Single();
                }
            }
        }