public string RejectUserRequest(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();
                IBookInfoDataProvider iBookInfoDataProvider = new BookInfoDataProvider();
                IBookDetailInfoDataProvider iBookDetailInfoDataProvider = new BookDetailInfoDataProvider();
                IProcessRecordDataProvider iProcessRecordDataProvider = new ProcessRecordDataProvider();

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

                iProcessRecordDataProvider.Add(processInfo);
                iBorrowAndReturnRecordInfoDataProviderdataProvider.Update(borrowAndReturnRecordInfo);
                iBookDetailInfoDataProvider.Update(bookDetailInfo);
                iBookInfoDataProvider.Update(bookModel.GetEntity());
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
            return "true";
        }
예제 #2
0
        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;
        }
예제 #4
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;
        }
예제 #5
0
        public static PublisherModel GetViewModel(PublisherInfo publisher)
        {
            PublisherModel model = new PublisherModel();

            model.ID = publisher.ID;
            model.PublisherName = publisher.PublisherName;
            model.PublisherIntroduction = publisher.PublisherIntroduction;

            IBookInfoDataProvider iBookInfoDataProvider = new BookInfoDataProvider();
            BookInfoCondition condition = new BookInfoCondition();
            condition.Publisher = publisher;

            if ( iBookInfoDataProvider.GetBookList(condition).Count() > 0)
            {
                model.IsUse = true;
            }

            return model;
        }
예제 #6
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;
        }
        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";
        }
예제 #8
0
        public PublisherInfo GetPublisherInfo(string pid, BookInfoDataProvider bookInfoDataProvider)
        {
            PublisherInfo info = null;

            if (!String.IsNullOrEmpty(pid))
            {
                long publishID = long.Parse(pid);
                info = bookInfoDataProvider.DataSource.PublisherInfos.FirstOrDefault(p => p.ID == publishID);
            }

            return info;
        }
예제 #9
0
        public BookInfo GetEntity()
        {
            BookInfo bookInfo = new BookInfo();

            BookInfoDataProvider bookInfoDataProvider = new BookInfoDataProvider();
            IBookInfoDataProvider iBookInfoDataProvider = bookInfoDataProvider;

            if (this.ID > 0)
            {

                bookInfo = iBookInfoDataProvider.GetBookInfoByID(this.ID);
            }

            bookInfo.ID = this.ID;
            bookInfo.BookName = this.BookName;
            bookInfo.ISBN = this.ISBN;

            bookInfo.Publish_Date = Convert.ToDateTime(this.Publish_Date);
            bookInfo.Price_Inventory = Decimal.Parse(this.Price_Inventory);
            bookInfo.Avaliable_Inventory = Convert.ToInt32(Convert.ToDecimal(this.Avaliable_Inventory));
            bookInfo.Max_Inventory = Convert.ToInt32(this.Max_Inventory);

            bookInfo.PublisherInfo = GetPublisherInfo(this.PublisherNameValue, bookInfoDataProvider);
            bookInfo.TempBookAndAuthors = GetAuthorInfoRelationList(this.AuthorNameValue, bookInfo, bookInfoDataProvider);
            bookInfo.TempBookAndCategorys = GetCategoryInfoRelationList(this.CatagoryNameValue, bookInfo, bookInfoDataProvider);

            return bookInfo;
        }
예제 #10
0
        public ICollection<BookAndCategoryRelation> GetCategoryInfoRelationList(string cIDs, BookInfo book, BookInfoDataProvider bookInfoDataProvider)
        {
            ICollection<BookAndCategoryRelation> list = new List<BookAndCategoryRelation>();
            if (!String.IsNullOrEmpty(cIDs))
            {
                var aArrary = cIDs.Split(UntityContent.SplitValueStr);
                foreach (var item in aArrary)
                {
                    if (!String.IsNullOrEmpty(item))
                    {
                        long catID = long.Parse(item);
                        BookAndCategoryRelation relationEntity = new BookAndCategoryRelation();
                        relationEntity.BookInfo = book;
                        relationEntity.CategoryInfo = bookInfoDataProvider.DataSource.CategoryInfos.FirstOrDefault(c => c.ID == catID);
                        list.Add(relationEntity);
                    }
                }
            }

            return list;
        }
예제 #11
0
        public ICollection<BookAndAuthorRelation> GetAuthorInfoRelationList(string aIDs, BookInfo book, BookInfoDataProvider bookInfoDataProvider)
        {
            ICollection<BookAndAuthorRelation> list = new List<BookAndAuthorRelation>();
            if (!String.IsNullOrEmpty(aIDs))
            {
                var aArrary = aIDs.Split(UntityContent.SplitValueStr);
                foreach (var item in aArrary)
                {
                    if (!String.IsNullOrEmpty(item))
                    {
                        long authID = long.Parse(item);
                        BookAndAuthorRelation relationEntity = new BookAndAuthorRelation();
                        relationEntity.BookInfo = book;
                        relationEntity.AuthorInfo = bookInfoDataProvider.DataSource.AuthorInfos.FirstOrDefault(a => a.ID == authID);
                        list.Add(relationEntity);
                    }
                }
            }

            return list;
        }
예제 #12
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;
        }