Exemplo n.º 1
0
        public async Task <IActionResult> PutUser([FromRoute] Guid id, [FromBody] User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != user.Id)
            {
                return(BadRequest());
            }

            _context.Entry(user).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public Book EditBook(Book entity)
        {
            var book = _context.books.Update(entity);

            _context.Entry(book).State = EntityState.Modified;
            return(book.Entity);
        }
        public void Update(Knjiga entity, int id)
        {
            Knjiga old = Get(id);

            if (old != null)
            {
                context.Entry(old).CurrentValues.SetValues(entity);
            }
        }
        public virtual void Update(Entity entity, int id)
        {
            Entity old = Get(id);

            if (old != null)
            {
                _context.Entry(old).CurrentValues.SetValues(entity);
            }
        }
        public void Update(Izdavac entity, int id)
        {
            Izdavac old = Get(id);

            if (old != null)
            {
                context.Entry(old).CurrentValues.SetValues(entity);
            }
        }
Exemplo n.º 6
0
        public ResultModel AddOrder(OrderDTO order)
        {
            ResultModel result = new ResultModel();

            BookDTO book = new BookDTO
            {
                AuthorId = order.Author.Id,
                Title    = order.Book.Title
            };

            int bookId = AddBook(book);

            if (bookId > 0)
            {
                using (var transaction = _context.Database.BeginTransaction())
                {
                    try
                    {
                        OrderLists item = new OrderLists
                        {
                            Book   = bookId,
                            Cost   = order.Cost,
                            Supply = order.Supply.Id
                        };

                        OrderLists item1 = (OrderLists)order;
                        item.Book = bookId;

                        _context.OrderLists.Add(item);

                        Supplies supply = _context.Supplies.FirstOrDefault(c => c.Id == order.Supply.Id);

                        double oldSumm = supply.Summ.HasValue ? supply.Summ.Value : 0;
                        supply.Summ = oldSumm + order.Cost;
                        _context.Entry(supply).State = EntityState.Modified;

                        _context.SaveChanges();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        result.Code    = OperationStatusEnum.UnexpectedError;
                        result.Message = ex.StackTrace;
                        transaction.Rollback();
                    }
                }
            }
            else
            {
                result.Code    = OperationStatusEnum.UnexpectedError;
                result.Message = "Ошибка при добавлении книги";
            }

            return(result);
        }
Exemplo n.º 7
0
        public ActionResult EditProfile(string email, string nikname, string pass, string NewPass, string NewPass2)
        {
            User au = (User)Session["AuthorizedUser"];

            if (!au.Pass.Equals(pass))
            {
                ViewBag.Massage = "Неправильный пароль";
                return(View());
            }
            else
            {
                if (NewPass != null && NewPass2 != null)
                {
                    if (NewPass.Equals(NewPass2))
                    {
                        au.Pass            = NewPass;
                        au.Nickname        = nikname;
                        au.Email           = email;
                        db.Entry(au).State = EntityState.Modified;
                        db.SaveChanges();
                        return(Redirect("/Home/Index"));
                    }
                    else
                    {
                        ViewBag.Massage = "Не удалось утвердить новый пароль";

                        return(View());
                    }
                }
                au.Nickname        = nikname;
                au.Email           = email;
                db.Entry(au).State = EntityState.Modified;
                db.SaveChanges();
                return(Redirect("/Home/Index"));
            }
        }
Exemplo n.º 8
0
        public void Edit(object sender, RoutedEventArgs e)
        {
            if (recordGrid.SelectedItem == null)
            {
                return;
            }
            Record record = recordGrid.SelectedItem as Record;

            EditRecord recordEdit = new EditRecord(new Record
            {
                Id       = record.Id,
                ReaderId = record.ReaderId,
                CardId   = record.CardId,
                Gave     = record.Gave,
                _Return  = record._Return,
                Returned = record.Returned,
                Reader   = readerGrid.SelectedItem as Reader,
                Card     = record.Card
            });

            if (recordEdit.ShowDialog() == true)
            {
                record = db.Records.Find(recordEdit.record.Id);
                if (record != null)
                {
                    record.ReaderId = recordEdit.record.Reader.Id;
                    record.CardId   = (int)recordEdit.cardCombo.SelectedItem;
                    record.Gave     = (DateTime)recordEdit.dpGave.SelectedDate;
                    record._Return  = (DateTime)recordEdit.dpHaveToReturn.SelectedDate;
                    record.Returned = recordEdit.dpReturned.SelectedDate;

                    record.Card = db.Cards.Find(record.CardId);

                    db.Entry(record).State = EntityState.Modified;
                    db.SaveChanges();
                    readerGridChange(readerGrid, null);
                }
            }
        }
Exemplo n.º 9
0
 public void Update(Book book)
 {
     db.Entry(book).State = EntityState.Modified;
 }
Exemplo n.º 10
0
 public void Update(Reader reader)
 {
     db.Entry(reader).State = EntityState.Modified;
 }
Exemplo n.º 11
0
 public void Update(TEntity item)
 {
     _context.Entry(item).State = EntityState.Modified;
     _context.SaveChanges();
 }
Exemplo n.º 12
0
 public void EditGroup(OperationGroup group)
 {
     db.Entry(group).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
Exemplo n.º 13
0
 public void Update(T obj)
 {
     db.Entry(obj).State = EntityState.Modified;
     db.SaveChanges();
 }
Exemplo n.º 14
0
 public void EditOperation(Operation operation)
 {
     db.Entry(operation).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
Exemplo n.º 15
0
 public void EditUser(User user)
 {
     db.Entry(user).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }