Exemple #1
0
        //Renews all Items in a loan as a new loan
        public void RenewLoan(LoansClientsInventoryDTO renewedDTO)
        {
            var loanNumber = renewedDTO.LoanNumber;

            using (var context = new SingularityDBContext())
            {
                var loan = context.LoanMasters.FirstOrDefault(
                    lm => string.Equals(lm.LoanNumber, loanNumber));

                if (loan != null)  // Always check for Null
                {
                    loan.IsActive = false;

                    loan.ClientOutcome = renewedDTO.ClientOutcome;
                    loan.LoanNotes     = renewedDTO.LoanNotes;
                    //do not worry about item damages for now
                }

                context.SaveChanges();

                foreach (var itemId in renewedDTO.InventoryItems)
                {
                    var item = context.InventoryItems.FirstOrDefault(
                        i => i.InventoryItemId == itemId.InventoryItemId);

                    if (item != null)
                    {
                        item.Availability = true;
                    }

                    context.SaveChanges();
                }
            }
        }
Exemple #2
0
        public void CheckInLoan_Nick(LoansClientsInventoryDTO checkInDTO) // copied into RenewLoan below
        {
            var loanNumber = checkInDTO.LoanNumber;

            using (var context = new SingularityDBContext())
            {
                var loan = context.LoanMasters.FirstOrDefault(
                    lm => string.Equals(lm.LoanNumber, loanNumber));

                if (loan != null)
                {
                    loan.IsActive = false;

                    loan.ClientOutcome = checkInDTO.ClientOutcome;
                    loan.LoanNotes     = checkInDTO.LoanNotes;
                    //loan.Damages = checkInDTO.Damages;
                }

                context.SaveChanges();

                var itemIds = GetInventoryItemIdsByLoanNumber(loanNumber);

                MarkInventoryItemsAsAvailable(context, itemIds);
            }
        }
Exemple #3
0
        public void EditLoan(LoansClientsInventoryDTO loanSubmission)
        {
            //have client id
            using (var context = new SingularityDBContext())
            {
                IEnumerable <LoanDetail> query = from itemId in loanSubmission.InventoryItemIds
                                                 select new LoanDetail
                {
                    InventoryItemId = itemId,
                    LoanMasterId    = loanSubmission.LoanMasterId,
                    Purpose         = loanSubmission.Purpose,
                    PurposeType     = loanSubmission.PurposeType
                };
                List <LoanDetail> loanDetailsList = query.ToList();

                ////Update New Inventory Items' Availability
                foreach (var itemId in query)
                {
                    var item = (from ii in context.InventoryItems
                                where ii.InventoryItemId == itemId.InventoryItemId
                                select ii).FirstOrDefault();

                    if (item != null)
                    {
                        item.Availability = false;
                    }

                    context.SaveChanges();
                }
                //now we can add a range of loan details to the loan details table
                context.LoanDetails.AddRange(loanDetailsList);
                context.SaveChanges();
            }
        }
        //Single Item
        //2. Executes single item checkin, routes back to ViewItems page
        public ActionResult CheckItemIn(LoansClientsInventoryDTO loan)
        {
            //Check in single item
            lm_services.CheckInLoanInventoryItem(loan);

            return(RedirectToAction("ViewItems", "Loan", new { @LoanNumber = loan.LoanNumber }));
        }
        //route to "are you sure?" page
        public ActionResult CancelLoan(LoansClientsInventoryDTO loan)
        {
            IList <LoansClientsInventoryDTO> allItems = lm_services.GetAllItems();
            IList <LoansClientsInventoryDTO> model    = allItems.Where(x => string.Equals(x.LoanNumber, loan.LoanNumber)).ToList();

            return(View(model));
        }
        public ActionResult UpdateLoan(LoansClientsInventoryDTO loan)
        {
            lm_services.EditLoan(loan);

            //Returns to Loan Index page
            return(RedirectToAction("Index", "Loan"));
        }
        //RenewLn.cshtm needs to pass the Id to CheckInRenewal First then collect up the input for the loan
        public ActionResult RenewAllItems(LoansClientsInventoryDTO loan)
        {
            //IList<LoansClientsInventoryDTO> model = lm_services.AddAllItemsAsNewLoan(loanNumber);
            //lm_services.SaveAllItemsAsNewLoan();

            return(RedirectToAction("Index", "Loan"));
        }
        public ActionResult CheckInRenewal(LoansClientsInventoryDTO loan)
        {
            //
            //Get the list of inventory items

            //1. Close loan, save outcomes, check in items
            lm_services.RenewLoan(loan);

            //2. create new loan with new loan object so creates new loan number

            // The DTO needs to send all of the data needed here
            //var submission = new LoansClientsInventoryDTO()
            //{
            //    ClientId = loan.ClientId,
            //    InventoryItemIds = loan.InventoryItemIds,
            //    IsActive = loan.IsActive,
            //    Purpose = loan.Purpose,
            //    PurposeType = loan.PurposeType
            //};

            lm_services.CreateRenewedLoan(loan);

            //3. use id to fill in loan with loan details

            //IList<LoansClientsInventoryDTO> model = lm_services.AddAllItemsAsNewLoan(loanNumber);
            //lm_services.SaveAllItemsAsNewLoan();

            return(RedirectToAction("Index", "Loan"));
        }
        //This is the page with the inventory items list in a loan
        //[HttpPost]
        //public ActionResult ViewItems(string loanNumber) //loanNumber
        //{
        //    IList<LoansClientsInventoryDTO> model = lm_services.ViewAllItems(loanNumber);

        //    //testing email
        //    //lm_services.NotifyEmail(loanNumber);

        //    //Remove Item will also show this page:
        //    //IList<LoansClientsInventoryDTO> model = lm_services.removeItem(viewButton);   Not worked out yet
        //    return View(model);
        //}



        #region Renew


        public ActionResult RenewLn(LoansClientsInventoryDTO loan)
        {
            IList <LoansClientsInventoryDTO> allItems = lm_services.GetAllItems();
            IList <LoansClientsInventoryDTO> model    = allItems.Where(x => int.Equals(x.LoanMasterId, loan.LoanMasterId)).ToList();

            return(View(model));
        }
        //[HttpPost]
        public ActionResult CancelItem(LoansClientsInventoryDTO loan)
        {
            //process delete here, return to ViewItems
            var loanNum = (lm_services.RemoveSingleItemFromLoanByLoanNumber(loan.InventoryItemId)).ToString();

            return(RedirectToAction("ViewItems", "Loan", new { LoanNumber = loanNum }));
            //return RedirectToAction("Index");
        }
        //Whole Loan
        //This is the View Page with text boxes & one param passed in. Doesn't do any checking-in
        public ActionResult CheckIn(LoansClientsInventoryDTO loan)   // Only gets LoanNumber passed in
        {
            //View all Items in Loan
            //IList<LoansClientsInventoryDTO> model = lm_services.GetAllItems();  //get all for this id
            IList <LoansClientsInventoryDTO> model = lm_services.ViewAllItems(loan.LoanNumber);

            return(View(model));
        }
Exemple #12
0
        public void CreateRenewedLoan(LoansClientsInventoryDTO loanSubmission)
        {
            using (var context = new SingularityDBContext())
            {
                var loanNumIncrement = LoanIncrement();

                var newLoan = new LoanMaster
                {
                    ClientId    = loanSubmission.ClientId,
                    DateCreated = DateTime.Now,
                    LoanNumber  = loanNumIncrement,
                    IsActive    = true,
                    IsDeleted   = false
                };

                context.LoanMasters.Add(newLoan);
                context.SaveChanges();

                LoanDetail[] itemsListed = new LoanDetail[loanSubmission.InventoryItems.Count];

                for (int i = 0; i < itemsListed.Length; i++)
                {
                    foreach (var itemId in loanSubmission.InventoryItems)
                    {
                        //if (loanSubmission.Availability)
                        //{
                        itemsListed[i] = new LoanDetail
                        {
                            InventoryItemId = itemId.InventoryItemId,
                            LoanMasterId    = newLoan.LoanMasterId,
                            Purpose         = loanSubmission.Purpose,
                            PurposeType     = loanSubmission.PurposeType
                        };
                        i++;
                        //};
                    }
                    ;
                    //break;
                }
                List <LoanDetail> loanDetailsList = itemsListed.ToList();

                //now we can add a range of loan details to the loan details table
                context.LoanDetails.AddRange(loanDetailsList);
                context.SaveChanges();

                //Update Inventory Items' Availability
                var itemIds = GetInventoryItemIdsByLoanNumber(newLoan.LoanNumber);
                MarkInventoryItemsAsNotAvailable(context, itemIds);
            }
        }
        //This displays Edit Loan page
        public ActionResult EditLoan(LoansClientsInventoryDTO loan)
        {
            IList <LoansClientsInventoryDTO> model = lm_services.GetAllItems();

            IList <LoansClientsInventoryDTO> filteredLoans =
                model.Where(item => int.Equals(item.LoanMasterId, loan.LoanMasterId))
                .ToList();

            //call jquery script, pass it json filtered object like above but json. Don't need above
            //var list = GetItemsListForEdit(loan.LoanMasterId);


            return(View(filteredLoans));
        }
Exemple #14
0
        //Updates the Inventory CheckIn DB fields
        public void CheckInLoanInventoryItem(LoansClientsInventoryDTO loan)
        {
            using (var context = new SingularityDBContext())
            {
                var loanNum = loan.LoanNumber;
                var itemIds = GetInventoryItemIdsByLoanNumber(loanNum);

                //itemIds is IEnumerable<int>
                //Update Item
                if (itemIds.Count() > 1)
                {
                    var itemId = (from ii in context.InventoryItems
                                  where ii.InventoryItemId == loan.InventoryItemId
                                  select ii).FirstOrDefault();

                    if (itemId != null)
                    {
                        itemId.Availability = true;
                        //itemId.Damages = loan.Damages;
                        //do not worry about item damages for now
                    }
                    context.SaveChanges();
                }
                else
                {
                    //CheckInLoan
                    var loanNumber = loan.LoanNumber;

                    var query = context.LoanMasters.FirstOrDefault(
                        lm => string.Equals(lm.LoanNumber, loanNumber));

                    if (query != null)
                    {
                        query.IsActive = false;
                    }

                    context.SaveChanges();

                    var itemIds2 = GetInventoryItemIdsByLoanNumber(loanNumber);

                    MarkInventoryItemsAsAvailable(context, itemIds2);
                }
            }
        }
        public ActionResult CheckInLoan(LoansClientsInventoryDTO loan)
        {
            //Check in multiple items
            //Get input from text boxes for Damages, Notes and ClientOutcome

            //TODO: rewire as necessary
            var dto = new CheckInWholeLoanDTO()
            {
                ClientOutcome = loan.ClientOutcome,
                Damages       = loan.Damages,
                LoanNotes     = loan.LoanNotes,
                LoanNumber    = loan.LoanNumber
            };

            lm_services.CheckInLoan_Nick(loan);


            //    //Returns to Loan Index page
            return(RedirectToAction("Index", "Loan"));
        }