public string ApproveUserRequest(string q)
        {
            try
            {
                JObject obj = JObject.Parse(q);
                long id = long.Parse((string)obj["idStr"]);

                UserRequestModel model = new UserRequestModel();
                model.ID = id;

                IBorrowAndReturnRecordInfoDataProvider iBorrowAndReturnRecordInfoDataProviderdataProvider = new BorrowAndReturnRecordInfoDataProvider();
                IProcessRecordDataProvider iProcessRecordDataProvider = new ProcessRecordDataProvider();

                BorrowAndReturnRecordInfo borrowAndReturnRecordInfo = new BorrowAndReturnRecordInfo();
                BookModel bookModel = new BookModel();
                BookDetailInfo bookDetailInfo = new BookDetailInfo();
                ProcessRecord processInfo = model.GetEntity(this.LoginUser(), q, false, out borrowAndReturnRecordInfo, out bookDetailInfo, out bookModel);

                iProcessRecordDataProvider.Add(processInfo);
                iBorrowAndReturnRecordInfoDataProviderdataProvider.Update(borrowAndReturnRecordInfo);
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
            return "true";
        }
        public ProcessRecord GetRevokeEntity(out BorrowAndReturnRecordInfo borrowAndReturnRecordInfo,
            out BookDetailInfo bookDetailInfo,
            out BookModel bookModel, UserInfo user)
        {
            IBorrowAndReturnRecordInfoDataProvider iBorrowAndReturnRecordInfoDataProviderdataProvider = new BorrowAndReturnRecordInfoDataProvider();
            IBookDetailInfoDataProvider iBookDetailInfoDataProvider = new BookDetailInfoDataProvider();
            IBookInfoDataProvider iBookInfoDataProvider = new BookInfoDataProvider();
            borrowAndReturnRecordInfo = iBorrowAndReturnRecordInfoDataProviderdataProvider.GetBorrowAndReturnRecordById(this.ID);
            bookDetailInfo = iBookDetailInfoDataProvider.GetBookDetailInfoByID(borrowAndReturnRecordInfo.BookDetailInfo.ID);
            BookInfo bookInfo = iBookInfoDataProvider.GetBookInfoByID(borrowAndReturnRecordInfo.BookDetailInfo.BookInfo.ID);

            ProcessRecord processInfo = new ProcessRecord();
            processInfo.UserInfo = user;
            processInfo.BorrowAndReturnRecordInfo = borrowAndReturnRecordInfo;
            processInfo.Status = RentRecordStatus.Revoked;
            processInfo.Comments = "You didn't take your book in limited time.";

            borrowAndReturnRecordInfo.Status = RentRecordStatus.Revoked;

            bookDetailInfo.Status = BookStatus.InStore;

            bookInfo.Avaliable_Inventory = bookInfo.Avaliable_Inventory + 1;
            bookModel = BookModel.GetViewModel(bookInfo);

            return processInfo;
        }
        public ProcessRecord GetEntity(UserInfo user, out BorrowAndReturnRecordInfo borrowAndReturnRecordInfo, out BookDetailInfo bookDetailInfo, out BookModel bookModel)
        {
            IBorrowAndReturnRecordInfoDataProvider iBorrowAndReturnRecordInfoDataProviderdataProvider = new BorrowAndReturnRecordInfoDataProvider();
            IBookDetailInfoDataProvider iBookDetailInfoDataProvider = new BookDetailInfoDataProvider();
            IBookInfoDataProvider iBookInfoDataProvider = new BookInfoDataProvider();

            borrowAndReturnRecordInfo = iBorrowAndReturnRecordInfoDataProviderdataProvider.GetBorrowAndReturnRecordById(this.ID);
            bookDetailInfo = iBookDetailInfoDataProvider.GetBookDetailInfoByID(borrowAndReturnRecordInfo.BookDetailInfo.ID);
            BookInfo bookInfo = iBookInfoDataProvider.GetBookInfoByID(borrowAndReturnRecordInfo.BookDetailInfo.BookInfo.ID);

            ProcessRecord processInfo = new ProcessRecord();
            processInfo.Status = RentRecordStatus.Returned;
            processInfo.UserInfo = user;
            processInfo.BorrowAndReturnRecordInfo = borrowAndReturnRecordInfo;
            processInfo.Comments = "";

            borrowAndReturnRecordInfo.Status = RentRecordStatus.Returned;
            borrowAndReturnRecordInfo.Return_Date = DateTime.Today;

            bookDetailInfo.Status = BookStatus.InStore;

            bookInfo.Avaliable_Inventory = bookInfo.Avaliable_Inventory + 1;
            bookModel = BookModel.GetViewModel(bookInfo);

            return processInfo;
        }
        public void Add(BookDetailInfo entity)
        {
            if (entity.BookInfo != null)
            {
                entity.BookInfo = this.DataSource.BookInfos.FirstOrDefault(b => b.ID == entity.BookInfo.ID);
            }

            if (entity.UserInfo != null)
            {
                entity.UserInfo = this.DataSource.UserInfos.FirstOrDefault(u => u.ID == entity.UserInfo.ID);
            }

            this.DataSource.BookDetailInfos.Add(entity);
            this.DataSource.SaveChanges();
        }
Esempio n. 5
0
        public ProcessRecord GetEntity(UserInfo user, string q, bool RejectOrApprove, out BorrowAndReturnRecordInfo borrowAndReturnRecordInfo, out BookDetailInfo bookDetailInfo, out BookModel bookModel)
        {
            JObject obj = JObject.Parse(q);
            string comments = (string)obj["comments"];
            bool errorOrNot = false;
            if (RejectOrApprove)
            {
                errorOrNot =( (string)obj["isChecked"] == "true" )? true : false;
            }

            IBorrowAndReturnRecordInfoDataProvider iBorrowAndReturnRecordInfoDataProviderdataProvider = new BorrowAndReturnRecordInfoDataProvider();
            IBookDetailInfoDataProvider iBookDetailInfoDataProvider = new BookDetailInfoDataProvider();
            IBookInfoDataProvider iBookInfoDataProvider = new BookInfoDataProvider();
            borrowAndReturnRecordInfo = iBorrowAndReturnRecordInfoDataProviderdataProvider.GetBorrowAndReturnRecordById(this.ID);
            bookDetailInfo = iBookDetailInfoDataProvider.GetBookDetailInfoByID(borrowAndReturnRecordInfo.BookDetailInfo.ID);
            BookInfo bookInfo = iBookInfoDataProvider.GetBookInfoByID(borrowAndReturnRecordInfo.BookDetailInfo.BookInfo.ID);

            ProcessRecord processInfo = new ProcessRecord();
            processInfo.UserInfo = user;
            processInfo.BorrowAndReturnRecordInfo = borrowAndReturnRecordInfo;
            processInfo.Comments = comments;
            bookModel = BookModel.GetViewModel(bookInfo);

            if (RejectOrApprove)
            {
                processInfo.Status = RentRecordStatus.Rejected;
                borrowAndReturnRecordInfo.Status = RentRecordStatus.Rejected;
                if (errorOrNot)
                {
                    bookDetailInfo.Status = BookStatus.Error;
                    bookInfo.Max_Inventory = bookInfo.Max_Inventory - 1;
                    bookModel.Max_Inventory = bookInfo.Max_Inventory.ToString();
                }
                else
                {
                    bookDetailInfo.Status = BookStatus.InStore;
                    bookInfo.Avaliable_Inventory = bookInfo.Avaliable_Inventory + 1;
                    bookModel.Avaliable_Inventory = bookInfo.Avaliable_Inventory.ToString();
                }
            }
            else
            {
                processInfo.Status = RentRecordStatus.Approved;
                borrowAndReturnRecordInfo.Status = RentRecordStatus.Approved;
            }

            return processInfo;
        }
        public void Update(BookDetailInfo entity)
        {
            BookDetailInfo bookdetail = this.GetBookDetailInfoByID(entity.ID);

            if (entity.BookInfo != null)
            {
                bookdetail.BookInfo = this.DataSource.BookInfos.FirstOrDefault(b => b.ID == entity.BookInfo.ID);
            }

            if (entity.UserInfo != null)
            {
                bookdetail.UserInfo = this.DataSource.UserInfos.FirstOrDefault(u => u.ID == entity.UserInfo.ID);
            }

            bookdetail.Status = entity.Status;
            bookdetail.Storage_Time = entity.Storage_Time;

            this.DataSource.SaveChanges();
        }
Esempio n. 7
0
        public ProcessRecord GetEntity(long id, UserInfo user, out BorrowAndReturnRecordInfo borrowAndReturnRecordInfo, out BookDetailInfo bookDetailInfo, out BookModel bookModel)
        {
            IBookDetailInfoDataProvider iBookDetailInfoDataProvider = new BookDetailInfoDataProvider();
            IBookInfoDataProvider iBookInfoDataProvider = new BookInfoDataProvider();

            ProcessRecord processInfo = new ProcessRecord();
            borrowAndReturnRecordInfo = new BorrowAndReturnRecordInfo();
            bookDetailInfo = iBookDetailInfoDataProvider.GetAvaliableBookDetailInfoByBookInfoID(id);
            BookInfo bookInfo = iBookInfoDataProvider.GetBookInfoByID(bookDetailInfo.BookInfo.ID);

            borrowAndReturnRecordInfo.BookDetailInfo = bookDetailInfo;
            borrowAndReturnRecordInfo.UserInfo = user;
            borrowAndReturnRecordInfo.Status = RentRecordStatus.Pending;
            borrowAndReturnRecordInfo.Borrow_Date = borrowAndReturnRecordInfo.CreateTime;
            borrowAndReturnRecordInfo.Forcast_Date = borrowAndReturnRecordInfo.CreateTime;
            borrowAndReturnRecordInfo.Return_Date = borrowAndReturnRecordInfo.CreateTime;

            processInfo.UserInfo = user;
            processInfo.BorrowAndReturnRecordInfo = borrowAndReturnRecordInfo;
            processInfo.Status = RentRecordStatus.Pending;

            bookDetailInfo.Status = BookStatus.Rent;

            bookModel = BookModel.GetViewModel(bookInfo, user);
            bookInfo.Avaliable_Inventory = bookInfo.Avaliable_Inventory - 1;
            bookModel.Avaliable_Inventory = bookInfo.Avaliable_Inventory.ToString();

            return processInfo;
        }
        private void EditBooksUpdateBook(BookDetailInfo books, AddDetailBookModel model)
        {
            BookInfo book = books.BookInfo;

            switch (model.BookStatusSelected)
            {
                case BookStatus.InStore:
                    if (model.BeforeStatus != BookStatus.InStore && model.BeforeStatus == BookStatus.Error)
                    {
                        book.Avaliable_Inventory = book.Avaliable_Inventory + 1;
                        book.Max_Inventory = book.Max_Inventory + 1;
                    }
                    else if (model.BeforeStatus != BookStatus.InStore)
                    {
                        book.Avaliable_Inventory = book.Avaliable_Inventory + 1;
                    }
                    break;
                case BookStatus.Rent:
                    if (model.BeforeStatus == BookStatus.InStore)
                    {
                        book.Avaliable_Inventory = book.Avaliable_Inventory - 1;
                    }
                    break;
                case BookStatus.Error:
                    if (model.BeforeStatus == BookStatus.InStore)
                    {
                        book.Avaliable_Inventory = book.Avaliable_Inventory - 1;
                        book.Max_Inventory = book.Max_Inventory - 1;
                    }
                    else if (model.BeforeStatus == BookStatus.Rent || model.BeforeStatus == BookStatus.OutStore)
                    {
                        book.Max_Inventory = book.Max_Inventory - 1;
                    }
                    break;
                case BookStatus.OutStore:
                    if (model.BeforeStatus == BookStatus.InStore)
                    {
                        book.Avaliable_Inventory = book.Avaliable_Inventory - 1;
                    }
                    break;
            }

            this.IBookInfoDataProvider.Update(book);
        }
        public string RevokeWaitingForTake(string q)
        {
            try
            {
                long id = long.Parse(q);
                WaitingForTakeModel model = new WaitingForTakeModel();
                model.ID = id;
                IBorrowAndReturnRecordInfoDataProvider iBorrowAndReturnRecordInfoDataProviderdataProvider = new BorrowAndReturnRecordInfoDataProvider();
                IProcessRecordDataProvider iProcessRecordDataProvider = new ProcessRecordDataProvider();
                IBookDetailInfoDataProvider iBookDetailInfoDataProvider = new BookDetailInfoDataProvider();
                IBookInfoDataProvider iBookInfoDataProvider = new BookInfoDataProvider();

                BorrowAndReturnRecordInfo borrowAndReturnRecordInfo = new BorrowAndReturnRecordInfo();
                BookDetailInfo bookDetailInfo = new BookDetailInfo();
                BookModel bookModel = new BookModel();
                ProcessRecord processInfo = model.GetRevokeEntity(out borrowAndReturnRecordInfo, out bookDetailInfo, out bookModel, this.LoginUser());

                iProcessRecordDataProvider.Add(processInfo);
                iBorrowAndReturnRecordInfoDataProviderdataProvider.Update(borrowAndReturnRecordInfo);
                iBookDetailInfoDataProvider.Update(bookDetailInfo);
                iBookInfoDataProvider.Update(bookModel.GetEntity());
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
            return "true";
        }
Esempio n. 10
0
        public BookDetailInfo GetEntity()
        {
            BookDetailInfo bookDetailInfo = new BookDetailInfo();

            bookDetailInfo.ID = this.ID;
            IUserInfoDataProvider userDataProvider = new UserInfoDataProvider();
            bookDetailInfo.UserInfo = userDataProvider.GetUserListByID(Convert.ToInt32(this.OwnerValue));
            IBookInfoDataProvider bookDataProvider = new BookInfoDataProvider();
            bookDetailInfo.BookInfo = bookDataProvider.GetBookInfoByID(this.BookID);
            bookDetailInfo.Status = this.BookStatusSelected;
            bookDetailInfo.Storage_Time = Convert.ToDateTime(this.Storage_Time);
            bookDetailInfo.CreateTime = DateTime.Now;

            return bookDetailInfo;
        }
Esempio n. 11
0
        public static AddDetailBookModel GetViewModel(BookDetailInfo bookDetailInfo)
        {
            AddDetailBookModel model = new AddDetailBookModel();
            model.ID = bookDetailInfo.ID;
            model.BookID = bookDetailInfo.BookInfo.ID;
            model.BookName = bookDetailInfo.BookInfo.BookName;
            model.ISBN = bookDetailInfo.BookInfo.ISBN;
            model.Owner = bookDetailInfo.UserInfo.DisplayName;
            model.OwnerValue = bookDetailInfo.UserInfo.ID.ToString();
            model.Status = EnumHelper.GetEnumDescription(bookDetailInfo.Status);
            model.Storage_Time = bookDetailInfo.Storage_Time.ToString(UntityContent.IOSDateTemplate);
            model.Create_Time = bookDetailInfo.CreateTime.ToString();

            model.BeforeStatus = bookDetailInfo.Status;

            //need to add logic
            model.IsUse = false;
            return model;
        }