Example #1
0
        public async Task <IActionResult> PutRequest(int id, Request request)
        {
            if (id != request.RequestId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "ID,TransactionStatus,transactionDate,dueDate,BookID")] Transaction transaction)
 {
     if (ModelState.IsValid)
     {
         db.Entry(transaction).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(transaction));
 }
Example #3
0
 public ActionResult Edit([Bind(Include = "Id,Name,Specification")] Author author)
 {
     if (ModelState.IsValid)
     {
         db.Entry(author).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(author));
 }
Example #4
0
 public ActionResult Edit([Bind(Include = "Id,AddressLine1,AddressLine2,City,State,Country,Pincode")] Address address)
 {
     if (ModelState.IsValid)
     {
         db.Entry(address).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(address);
 }
Example #5
0
 public ActionResult Edit([Bind(Include = "Id,Name,MobileNumber,AddressId,IsActive,LoginDetailId")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Example #6
0
 public ActionResult Edit([Bind(Include = "Id,TypeOfMembership,IsStudent,ExpiryDate,UserId")] Member member)
 {
     if (ModelState.IsValid)
     {
         db.Entry(member).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = new SelectList(db.Users, "Id", "Name", member.UserId);
     return(View(member));
 }
Example #7
0
 public ActionResult Edit([Bind(Include = "Id,Name,AddressId")] Publisher publisher)
 {
     if (ModelState.IsValid)
     {
         db.Entry(publisher).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AddressId = new SelectList(db.Addresses, "Id", "AddressLine1", publisher.AddressId);
     return(View(publisher));
 }
Example #8
0
 public ActionResult Edit([Bind(Include = "Id,Title,AuthorId,PublisherId,TotalCount,AvailableCount,BorrowedCount")] Book book)
 {
     if (ModelState.IsValid)
     {
         db.Entry(book).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AuthorId    = new SelectList(db.Authors, "Id", "Name", book.AuthorId);
     ViewBag.PublisherId = new SelectList(db.Publishers, "Id", "Name", book.PublisherId);
     return(View(book));
 }
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         using (LibraryManagementContext db = new LibraryManagementContext())
         {
             db.Entry(user).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     return(View(user));
 }
        public ActionResult Create(BookBorrow collection)
        {
            try
            {
                // TODO: Add insert logic here
                collection.BorrowDate = DateTime.Today;
                collection.ReturnDate = "--";
                _context.Borrow.Add(collection);
                _context.SaveChanges();

                int  BookId = _context.Books.FirstOrDefault(x => x.BookName == collection.BookName).Id;
                Book Book   = _context.Books.Find(BookId);
                Book.NumberOfBooksIsBorrowed += 1;
                _context.Entry(Book).State    = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #11
0
 public ActionResult Edit(int id, RegisteredPerson collection)
 {
     try
     {
         // TODO: Add update logic here
         _context.Entry(collection).State = System.Data.Entity.EntityState.Modified;
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Example #12
0
 public ActionResult Edit([Bind(Include = "Id,IssueDate,ReturnDate,IsReturned,MemberId,BookId")] BorrowedBy borrowedBy)
 {
     if (ModelState.IsValid)
     {
         db.Entry(borrowedBy).State = EntityState.Modified;
         db.SaveChanges();
         var editBorrowedBy = new EditBorrowedBy();
         if (!borrowedBy.IsReturned)
         {
             editBorrowedBy.ReduceBookCountAvailability(borrowedBy);
         }
         else
         {
             editBorrowedBy.IncreaseBookCountAvailability(borrowedBy);
         }
         return(RedirectToAction("Index"));
     }
     ViewBag.BookId   = new SelectList(db.Books, "Id", "Title", borrowedBy.BookId);
     ViewBag.MemberId = new SelectList(db.Members, "Id", "Id", borrowedBy.MemberId);
     return(View(borrowedBy));
 }
Example #13
0
        public virtual async Task <T> UpdateAsnyc(T item)
        {
            try
            {
                var result = await _dbSet.SingleOrDefaultAsync(e => e.Id.Equals(item.Id));

                if (result == null)
                {
                    return(null);
                }

                item.UpdateAt = DateTime.UtcNow;
                item.CreateAt = result.CreateAt;

                _db.Entry(result).CurrentValues.SetValues(item);
                await _db.SaveChangesAsync();
            }
            catch (Exception e)
            {
                throw e;
            }

            return(item);
        }