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;
        }
Example #2
0
        public static int GetCanBorrowCount(UserInfo userInfo)
        {
            int returnInt = 0;
            switch (userInfo.Grade)
            {
                case UserGrade.Resign:
                    returnInt = 0;
                    break;

                case UserGrade.Junior:
                    returnInt = 2;
                    break;

                case UserGrade.Ordinary:
                case UserGrade.Senior:
                    returnInt = 3;
                    break;

                case UserGrade.Admin:
                case UserGrade.VIP:
                case UserGrade.PrepVolunteer:
                    returnInt = 5;
                    break;
            }

            return returnInt;
        }
        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 DelayRecord GetEntity(UserInfo user, out BorrowAndReturnRecordInfo borrowAndReturnRecordInfo)
        {
            IBorrowAndReturnRecordInfoDataProvider iBorrowAndReturnRecordInfoDataProviderdataProvider = new BorrowAndReturnRecordInfoDataProvider();
            borrowAndReturnRecordInfo = iBorrowAndReturnRecordInfoDataProviderdataProvider.GetBorrowAndReturnRecordById(this.ID);
            borrowAndReturnRecordInfo.Forcast_Date = borrowAndReturnRecordInfo.Forcast_Date.AddDays(30);

            DelayRecord delayRecord = new DelayRecord();
            delayRecord.BorrowAndReturnRecordInfo = borrowAndReturnRecordInfo;
            delayRecord.UserInfo = user;
            return delayRecord;
        }
 public int GetBooksInHandCount(UserInfo userInfo)
 {
     int returnInt = 0;
     IEnumerable<BorrowAndReturnRecordInfo> borrowAndReturnList = this.DataSource.BorrowAndReturnRecordInfos;
     borrowAndReturnList = borrowAndReturnList.Where(b => b.UserInfo.ID == userInfo.ID);
     if (borrowAndReturnList.Count() > 0)
     {
         borrowAndReturnList = borrowAndReturnList.Where(b => b.Status == RentRecordStatus.Approved
             || b.Status == RentRecordStatus.Pending || b.Status == RentRecordStatus.Taked);
     }
     returnInt = borrowAndReturnList.Count();
     return returnInt;
 }
        public UserInfo UpdateEntity(UserInfo user)
        {
            user.DisplayName = this.DisplayName;
            user.Email = this.Email;
            user.Floor = GetFloor(this.SelectedFloor);
            user.PM = this.PM;
            user.Team = this.Team;
            user.Chinese_Name = this.Chinese_Name;
            user.Wechat = this.Wechat;
            user.Remark = this.Remark;

            return user;
        }
Example #7
0
        public UserInfo GetEntity()
        {
            UserInfo user = new UserInfo();

            user.DisplayName = this.DisplayName;
            user.LoginName = this.LoginName;
            user.Password = this.Password;
            user.RealName = this.RealName;
            user.Email = this.Email;
            user.Grade = UserGrade.Junior;

            return user;
        }
        public int GetCountByUser(BookInfo bookInfo, UserInfo userInfo)
        {
            IEnumerable<SupportORAgainst> supportORAgainsts
                = this.DataSource.SupportORAgainstInfos.Where(c => c.BookInfo.ID == bookInfo.ID);

            if (userInfo != null)
            {
                supportORAgainsts = supportORAgainsts.Where(c => c.UserInfo.ID == userInfo.ID);
                return supportORAgainsts.Count();
            }
            else
            {
                return 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 int GetCount(BookInfo bookInfo, Boolean supportOrObjection = true, UserInfo userInfo = null)
        {
            IEnumerable<SupportAndObjectionInfo> supportAndObjections
                = this.DataSource.SupportAndObjectionInfos.Where(c => c.BookInfo.ID == bookInfo.ID);

            if (userInfo != null)
            {
                supportAndObjections = supportAndObjections.Where(c => c.UserInfo.ID == userInfo.ID);
            }
            else
            {
                supportAndObjections = supportAndObjections.Where(c => c.SupportOrObjection == supportOrObjection);
            }

            return supportAndObjections.Count();
        }
        public ProcessRecord GetTakeEntity(out BorrowAndReturnRecordInfo borrowAndReturnRecordInfo,UserInfo user)
        {
            IBorrowAndReturnRecordInfoDataProvider iBorrowAndReturnRecordInfoDataProviderdataProvider = new BorrowAndReturnRecordInfoDataProvider();
            borrowAndReturnRecordInfo = iBorrowAndReturnRecordInfoDataProviderdataProvider.GetBorrowAndReturnRecordById(this.ID);

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

            borrowAndReturnRecordInfo.Status = RentRecordStatus.Taked;
            borrowAndReturnRecordInfo.Borrow_Date = DateTime.Today;
            borrowAndReturnRecordInfo.Forcast_Date = DateTime.Today.AddDays(30);

            return processInfo;
        }
        public static EditAccountModel GetViewModel(UserInfo user)
        {
            EditAccountModel model = new EditAccountModel();

            model.DisplayName = user.DisplayName;
            model.LoginName = user.LoginName;
            model.RealName = user.RealName;
            model.Email = user.Email;
            model.Floor = user.Floor;
            model.PM = user.PM;
            model.Team = user.Team;
            model.Chinese_Name = user.Chinese_Name;
            model.Wechat = user.Wechat;
            model.Grade = EnumHelper.GetEnumDescription(user.Grade);
            model.Late_point = user.Late_point;
            model.Remark = user.Remark;

            return model;
        }
Example #13
0
        public static bool GetCanRenewLevel(UserInfo userInfo)
        {
            bool returnBool = true;
            switch (userInfo.Grade)
            {
                case UserGrade.Resign:
                case UserGrade.Junior:
                    returnBool = false;
                    break;

                case UserGrade.PrepVolunteer:
                case UserGrade.Ordinary:
                case UserGrade.Senior:
                case UserGrade.Admin:
                case UserGrade.VIP:
                    break;
            }

            return returnBool;
        }
Example #14
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;
        }
 public void Add(UserInfo userInfo)
 {
     this.DataSource.UserInfos.Add(userInfo);
     this.DataSource.SaveChanges();
 }
Example #16
0
        public static UserModel GetViewModel(UserInfo user)
        {
            UserModel model = new UserModel();

            model.ID = user.ID;
            model.DisplayName = user.DisplayName;
            model.RealName = user.RealName;
            model.Password = user.Password;
            model.LoginName = user.LoginName;
            model.Email = user.Email;
            model.Floor = user.Floor;
            model.SelectedFloor = user.Floor.ToString();
            model.PM = user.PM;
            model.Team = user.Team;
            model.Chinese_Name = user.Chinese_Name;
            model.Wechat = user.Wechat;
            model.Grade = user.Grade;
            model.GradeDisplay = EnumHelper.GetEnumDescription(user.Grade);
            model.Late_point = user.Late_point;
            user.Remark = user.Remark;
            return model;
        }
Example #17
0
        public static BookToRentModel GetViewMode(BookInfo bookInfo, UserInfo userInfo)
        {
            BookToRentModel model = new BookToRentModel();
            model.ID = bookInfo.ID;
            model.BookName = bookInfo.BookName;

            string displayName = string.Empty;
            string authorNameValue = string.Empty;
            model.AuthorName = BookManage.BookModel.GetAuthorName(bookInfo, out displayName, out authorNameValue);
            model.AuthorName = displayName;

            model.ISBN = bookInfo.ISBN;

            if (bookInfo.PublisherInfo != null)
            {
                model.PublisherName = bookInfo.PublisherInfo.PublisherName;
            }
            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.Book_Description = "Waiting for DB......";

            int canBorrowCount =  Unity.Helper.DataUnity.GetCanBorrowCount(userInfo);
            IBorrowAndReturnRecordInfoDataProvider iBorrowAndReturnRecordInfoDataProvider =
                new BorrowAndReturnRecordInfoDataProvider();
            int alreadyBorrowedCount = iBorrowAndReturnRecordInfoDataProvider.GetBooksInHandCount(userInfo);

            model.Can_Borrow_Count = canBorrowCount.ToString();
            if (alreadyBorrowedCount >= canBorrowCount)
            {
                model.Still_Can_Borrow_Count = Convert.ToInt32(0).ToString();
                model.Still_Can_Borrow = false;
            }
            else
            {
                model.Still_Can_Borrow_Count = (canBorrowCount - alreadyBorrowedCount).ToString();
                model.Still_Can_Borrow = true;
            }

            return model;
        }
Example #18
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 IEnumerable<DelayRecord> GetDelayRecordList(UserInfo userInfo)
 {
     return this.DataSource.DelayRecords.Where(c => c.UserInfo.ID == userInfo.ID);
 }
Example #20
0
        public UserInfo GetEntity()
        {
            UserInfo user = new UserInfo();

            user.ID = this.ID;
            user.DisplayName = this.DisplayName;
            user.LoginName = this.LoginName;
            user.Password = this.Password;
            user.RealName = this.RealName;
            user.Email = this.Email;
            user.Floor = GetFloor(this.SelectedFloor);
            user.PM = this.PM;
            user.Team = this.Team;
            user.Chinese_Name = this.Chinese_Name;
            user.Wechat = this.Wechat;
            user.Grade = this.Grade;
            user.Late_point = this.Late_point;
            user.Remark = this.Remark;
            return user;
        }
        public void Update(UserInfo userInfo)
        {
            UserInfo user = this.GetUserListByID(userInfo.ID);
            user.DisplayName = userInfo.DisplayName;
            user.RealName = userInfo.RealName;
            user.LoginName = userInfo.LoginName;
            user.Password = userInfo.Password;
            user.Email = userInfo.Email;
            user.Floor = userInfo.Floor;
            user.PM = userInfo.PM;
            user.Team = userInfo.Team;
            user.Chinese_Name = userInfo.Chinese_Name;
            user.Wechat = userInfo.Wechat;
            user.Grade = userInfo.Grade;
            user.Late_point = userInfo.Late_point;
            user.Remark = userInfo.Remark;

            this.DataSource.SaveChanges();
        }
 public IEnumerable<BorrowAndReturnRecordInfo> GetBorrowAndReturnRecordListByStatusAndUser(RentRecordStatus status, UserInfo userInfo)
 {
     IEnumerable<BorrowAndReturnRecordInfo> returnList = GetBorrowAndReturnRecordListByStatus(status);
     returnList = returnList.Where(b => b.UserInfo.ID == userInfo.ID);
     return returnList;
 }
        private string ValidateDuplicate(UserInfo userInfo)
        {
            string resultStr = null;
            if (this.IUserInfoDataProvider.GetUserListByLoginName(userInfo.LoginName).Count() > 0)
            {
                resultStr = "LoginName is exsit";
            }
            else
            {
                if (this.IUserInfoDataProvider.GetUserListByEmail(userInfo.Email) != null)
                {
                    resultStr = "This Email is exsit";
                }
            }

            return resultStr;
        }