Esempio n. 1
0
        public void IncreaseBookCountAvailability(BorrowedBy borrowedBy)
        {
            var books = db.Books.Find(borrowedBy.BookId);

            books.AvailableCount += 1;
            books.BorrowedCount  -= 1;
            db.SaveChanges();
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "Id,Name,Specification")] Author author)
        {
            if (ModelState.IsValid)
            {
                db.Authors.Add(author);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(author));
        }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "ID,TransactionStatus,transactionDate,dueDate,BookID")] Transaction transaction)
        {
            if (ModelState.IsValid)
            {
                db.Transactions.Add(transaction);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(transaction));
        }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "bookID,transactionID,bookTitle,author,loanStatus")] Book book)
        {
            if (ModelState.IsValid)
            {
                bookDataGateway.Insert(book);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(book));
        }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "Id,AddressLine1,AddressLine2,City,State,Country,Pincode")] Address address)
        {
            if (ModelState.IsValid)
            {
                db.Addresses.Add(address);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(address);
        }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "Id,Name,AddressId")] Publisher publisher)
        {
            if (ModelState.IsValid)
            {
                db.Publishers.Add(publisher);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AddressId = new SelectList(db.Addresses, "Id", "AddressLine1", publisher.AddressId);
            return(View(publisher));
        }
Esempio n. 7
0
        public ActionResult Create([Bind(Include = "Id,TypeOfMembership,IsStudent,ExpiryDate,UserId")] Member member)
        {
            if (ModelState.IsValid)
            {
                db.Members.Add(member);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId = new SelectList(db.Users, "Id", "Name", member.UserId);
            return(View(member));
        }
Esempio n. 8
0
        public ActionResult Create([Bind(Include = "Id,Title,AuthorId,PublisherId,TotalCount,AvailableCount,BorrowedCount")] Book book)
        {
            if (ModelState.IsValid)
            {
                db.Books.Add(book);
                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));
        }
Esempio n. 9
0
        public ActionResult Create([Bind(Include = "Id,Name,MobileNumber,AddressId,IsActive,LoginDetailId")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AddressId     = new SelectList(db.Addresses, "Id", "AddressLine1", user.AddressId);
            ViewBag.LoginDetailId = new SelectList(db.LoginDetails, "Id", "LoginName", user.LoginDetailId);
            return(View(user));
        }
Esempio n. 10
0
 public ActionResult Create(RegisteredPerson collection)
 {
     try
     {
         // TODO: Add insert logic here
         _context.Person.Add(collection);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(BookCategory collection)
 {
     try
     {
         // TODO: Add insert logic here
         _context.BookCategory.Add(collection);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(Book collection)
 {
     try
     {
         // TODO: Add insert logic here
         collection.NumberOfBooksIsBorrowed = 0;
         _context.Books.Add(collection);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 13
0
        public ActionResult DeleteConfirm(int?id)
        {
            using (LibraryManagementContext db = new LibraryManagementContext())
            {
                Models.Book book = db.Books.Find(id);
                db.Books.Remove(book);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
        }
        public ActionResult DeleteConfirm(int?id)
        {
            using (LibraryManagementContext db = new LibraryManagementContext())
            {
                User user = db.Users.Find(id);
                db.Users.Remove(user);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
        }
        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());
            }
        }
 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(User user)
 {
     using (LibraryManagementContext db = new LibraryManagementContext())
     {
         if (ModelState.IsValid)
         {
             db.Users.Add(user);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(user));
     }
 }
Esempio n. 18
0
        public ActionResult Create([Bind(Include = "Id,IssueDate,ReturnDate,IsReturned,MemberId,BookId")] BorrowedBy borrowedBy)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.borrowedBies.Add(borrowedBy);
                    db.SaveChanges();
                    var createBorrowedBy = new CreateBorrowedBy();
                    createBorrowedBy.ReduceBookCountAvailability(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));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "BorrowedBy", "Create")));
            }
        }
Esempio n. 19
0
        public ActionResult CreateLogin([Bind(Include = "Id,LoginName,Password,IsActive,TypeofUser")] LoginDetail logindetail)
        {
            bool ErrorFlag = false;

            if (ModelState.IsValid)
            {
                db.LoginDetails.Add(logindetail);
                int NumCount     = 0;
                int splCharCount = 0;
                int Uppercase    = 0;
                int Lowercase    = 0;
                foreach (char c in logindetail.Password)
                {
                    if (Regex.IsMatch(c.ToString(), @"[A-Z]"))
                    {
                        Uppercase++;
                    }
                    if (Regex.IsMatch(c.ToString(), @"[a-z]"))
                    {
                        Lowercase++;
                    }
                    if (Regex.IsMatch(c.ToString(), @"[0-9]"))
                    {
                        NumCount++;
                    }
                    if (Regex.IsMatch(c.ToString(), @"[^a-zA-Z0-9]"))
                    {
                        splCharCount++;
                    }
                }
                if (logindetail.Password.Length < 4 || Uppercase < 1 || Lowercase < 1 || NumCount < 1 || splCharCount < 1)
                {
                    ErrorFlag = true;
                    ModelState.AddModelError("Password", "Passwords must be at least 4 characters and contain the following: upper case (A - Z), lower case (a - z), number(0 - 9) and special character(e.g. !@#$%^&*)");
                }
                if (!ErrorFlag)
                {
                    db.SaveChanges();
                }
                else
                {
                    return(View(logindetail));
                }
                return(RedirectToAction("Login"));
            }

            return(View(logindetail));
        }
 public ActionResult PostUser([FromBody] UsersPoco poco)
 {
     _context.UsersPocos.Add(poco);
     _context.SaveChanges();
     return(Ok());
 }