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";
        }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 5
0
        public static DetailBookModel GetViewModel(BookInfo bookInfo, UserInfo userInfo)
        {
            IBookDetailInfoDataProvider iBookDetailInfoDataProvider = new BookDetailInfoDataProvider();
            DetailBookModel model = new DetailBookModel();

            model.ID = bookInfo.ID;
            model.BookName = bookInfo.BookName;
            model.ISBN = bookInfo.ISBN;

            if (bookInfo.PublisherInfo != null)
            {
                model.PublisherName = bookInfo.PublisherInfo.PublisherName;
                model.PublisherNameValue = bookInfo.PublisherInfo.ID.ToString();
                model.PublisherDisplayDescription = bookInfo.PublisherInfo.PublisherIntroduction;
            }

            model.Publish_Date = bookInfo.Publish_Date.ToString(UntityContent.IOSDateTemplate);
            model.Avaliable_Inventory = Convert.ToInt32(bookInfo.Avaliable_Inventory).ToString();
            model.Max_Inventory = Convert.ToInt32(bookInfo.Max_Inventory).ToString();
            model.Price_Inventory = bookInfo.Price_Inventory.ToString("F");

            string categoryNameValue = string.Empty;
            model.CatagoryName = GetCategoryName(bookInfo, out categoryNameValue);
            model.CatagoryNameValue = categoryNameValue;

            string displayName = string.Empty;
            string authorNameValue = string.Empty;
            model.AuthorName = GetAuthorName(bookInfo, out displayName, out authorNameValue);
            model.AuthorDisplayName = displayName;
            model.AuthorNameValue = authorNameValue;

            model.IsAvaliable = bookInfo.Avaliable_Inventory > 0 ? true : false;

            ISupportORAgainstInfoDataProvider dataProvider = new SupportORAgainstInfoDataProvider();
            model.IsAvaliableForSupport = dataProvider.GetCountByUser(bookInfo, userInfo) >= 1 ? false : true;
            model.Supports = dataProvider.GetCountByStatus(bookInfo, SupportAgainstStatus.Support).ToString();
            model.Objections = dataProvider.GetCountByStatus(bookInfo, SupportAgainstStatus.Against).ToString();

            return model;
        }
Exemplo n.º 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";
        }