예제 #1
0
        /// <summary>
        /// Based on the the finance option set the months for calculations
        /// </summary>
        /// <param name="requestParameters"></param>
        /// <returns></returns>
        public async Task <LoanViewModel> GetPaymentSchedule(LoanViewModel requestParameters)
        {
            LoanViewModel output = new LoanViewModel();

            output = requestParameters;
            int loanMonths = 0;

            switch (output.Term)
            {
            case "One":
            {
                loanMonths = 12;
                break;
            }

            case "Two":
            {
                loanMonths = 24;
                break;
            }

            case "Three":
            {
                loanMonths = 36;
                break;
            }
            }

            output.PaymentSchedule = GetLoanScheduleDetails(requestParameters, loanMonths);


            return(output);
        }
예제 #2
0
        /// <summary>
        /// Calculates the loan schedule
        /// </summary>
        /// <param name="requestParameters"></param>
        /// <param name="loanMonths"></param>
        /// <returns></returns>
        private List <SheduledPayments> GetLoanScheduleDetails(LoanViewModel requestParameters, int loanMonths)
        {
            decimal  paymentAmount           = requestParameters.LoanAmount / loanMonths;
            DateTime lastPaymentDate         = requestParameters.Deliverydate;
            List <SheduledPayments> payments = new List <SheduledPayments>();

            for (int i = 1; i <= loanMonths; i++)
            {
                SheduledPayments item = new SheduledPayments();
                item.PaymentDate      = GetFirstMondayOfTheMonth(lastPaymentDate);
                item.PaymentAmount    = paymentAmount;
                item.RemainingBalance = requestParameters.LoanAmount - (paymentAmount * i);
                item.TotalPaid        = paymentAmount * i;
                payments.Add(item);
                lastPaymentDate = item.PaymentDate;
            }

            //add the arrangement and the completion fees on the first and the last entry
            var firstPayment = payments.First();

            firstPayment.PaymentAmount = paymentAmount + requestParameters.ArrangementFee;

            var lastPayment = payments.Last();

            lastPayment.PaymentAmount = paymentAmount + requestParameters.CompletionFee;
            return(payments);
        }
예제 #3
0
        public List <getAllUserAndRoles> getAllUsersAndRoles()
        {
            //---- Create object of our entities class.
            try
            {
                LoanViewModel lvm  = new LoanViewModel();
                var           user = "******";
                users.Email = user;
                users.id    = DataReaders.selectUserID(users);

                var results = (from a in db.UserRoles
                               join c in db.Roles on a.RoleId equals c.RoleId
                               join b in db.Users on a.UserId equals b.id
                               //where a.UserId == users.id
                               select new Models.getAllUserAndRoles {
                    userid = b.id, roleid = c.RoleId, rolename = c.RoleName, email = b.Email, id = a.id
                }).ToList();
                var model = new LoanViewModel
                {
                    getAllUserAndRoless = results.ToList(),
                };
                lvm.getAllUserAndRoless = results;
                return(lvm.getAllUserAndRoless.ToList());
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
예제 #4
0
 public ActionResult CreateService(LoanViewModel lvm, FormCollection form)
 {
     try
     {
         var    LoggedInuser = new LogginHelper();
         string user         = LoggedInuser.LoggedInUser();
         if (user != "")
         {
             var          userid = DataReaders.GetUserIdByEmail(user);
             GLobalClient gc     = new GLobalClient();
             ViewBag.listMerchant             = gc.findAllMerchant();
             lvm.CustomerServices.Customer_FK = userid;
             lvm.CustomerServices.DateCreated = DateTime.Now;
             lvm.CustomerServices.ValueDate   = DateTime.Now.ToString();
             lvm.CustomerServices.Merchant_Fk = Convert.ToInt16(form["ID"]);
             lvm.CustomerServices.ValueTime   = "1";
             lvm.CustomerServices.isVissible  = 1;
             lvm.CustomerServices.OtherLabel  = "other";
             gc.CreateCustomerService(lvm.CustomerServices);
             TempData["Message"] = "New Service Added";
             return(View("CreateService"));
         }
         else
         {
             return(View("CreateService"));
         }
     }
     catch (Exception ex)
     {
         WebLog.Log(ex.Message.ToString());
         return(null);
     }
 }
예제 #5
0
        public ActionResult EditCustomerService(LoanViewModel lvm)
        {
            try
            {
                GLobalClient gc = new GLobalClient();
                ViewBag.listMerchant = gc.findAllMerchant();
                //lvm.CustomerServices = gc.FindCustomerService(lvm);
                CustomerService _cs = new CustomerService();
                _cs.ID                 = lvm.CustomerServices.ID;
                _cs.CustomerID         = lvm.CustomerServices.CustomerID;
                _cs.CustomerIDLabel    = lvm.CustomerServices.CustomerIDLabel;
                _cs.PackageTypeIDLabel = lvm.CustomerServices.PackageTypeIDLabel;
                _cs.PackageType        = lvm.CustomerServices.PackageType;
                _cs.OtherLabel         = lvm.CustomerServices.OtherLabel;
                _cs.OtherLabelID       = lvm.CustomerServices.OtherLabelID;


                var UpdateCustomerService = DataCreators.UpdateCustomerService(_cs);
                // return View("AllCustomerService");
                return(RedirectToAction("AllCustomerService", "Customer", new { area = "" }));
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
예제 #6
0
        public ActionResult ResetPassword(FormCollection form, LoanViewModel lvm, DataAccessLayerT.DataManager.User users)
        {
            try
            {
                if (users.PaswordVal != "")
                {
                    string value     = Convert.ToString(form["value"]);
                    string password  = users.PaswordVal;
                    string rpassword = Convert.ToString(form["rpassword"]);

                    if (password != rpassword)
                    {
                        TempData["ErrMsg"] = "Password Does Not Match";
                        return(View(users));
                    }
                    //string rpassword = lvm.AccountsModel.confirmPassword;

                    ResetPasswords(value, users);
                }
                return(View());
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
예제 #7
0
        public ActionResult UserRole(LoanViewModel lvm, FormCollection form)
        {
            try
            {
                int roleid = Convert.ToInt16(form["roleid"]);
                int userid = Convert.ToInt16(form["id"]);
                userroles.RoleId = roleid;
                userroles.UserId = userid;
                userroles.RoleId = DataReaders.selectRolesByName(userroles);
                if (userroles.RoleId != 0)
                {
                    TempData["message"] = "User Already Have This Role";
                    return(View(""));
                }
                else

                {
                    userroles.RoleId     = roleid;
                    userroles.UserId     = userid;
                    userroles.IsVissible = 1;
                    userroles.dates      = DateTime.Now;

                    DataCreators.InsertUserRoles(userroles);
                    TempData["message"]     = "User n Roles Created Succesfully";
                    lvm.getAllUserAndRoless = getAllUsersAndRoles();
                }
                return(View(""));
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
        public async Task <HttpResponseMessage> Phase1(int campaignId, [FromBody] LoanViewModel Model)
        {
            try
            {
                Model.Id = campaignId;
                var identity = (ClaimsIdentity)User.Identity;
                var claims   = identity.Claims.Select(x => new { type = x.Type, value = x.Value });
                var userId   = claims.Where(a => a.type == "UserId").Select(a => a.value).SingleOrDefault().ToString();;
                var userName = claims.Where(a => a.type == ClaimTypes.Name).Select(a => a.value).SingleOrDefault().ToString();

                var userDisName = claims.Where(a => a.type == "DisplayName").Select(a => a.value).SingleOrDefault().ToString();
                Model.UserId   = Convert.ToInt32(userId);
                Model.UserName = userName;

                Model.UserDisplayName = userDisName;
                int CampaignId = await IService.CreateLoanPhase1(Model);

                ResponseObject response = new ResponseObject();
                response.campaignId  = CampaignId.ToString();
                response.ResponseMsg = "Campaign Updated- Phase 1 successfully";
                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception ex)
            {
                ResponseObject response = new ResponseObject();
                response.ExceptionMsg = ex.InnerException.ToString();
                response.ResponseMsg  = "Campaign Phase 1 Updation is ended with an exception";
                response.ErrorCode    = HttpStatusCode.InternalServerError.ToString();
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, response));
            }
        }
예제 #9
0
        public ActionResult AddLoan(LoanViewModel c)
        {
            ViewBag.Title = "Add Loan";

            if (string.IsNullOrWhiteSpace(c.FirstName) == false)
            {
                if (c.FirstName.Contains(" ") == true)
                {
                    ModelState.AddModelError(nameof(c.FirstName), "Please no special characters or spaces in first name.");
                }
            }

            if (string.IsNullOrWhiteSpace(c.LastName) == false)
            {
                if (c.LastName.Contains(" ") == true)
                {
                    ModelState.AddModelError(nameof(c.LastName), "Please no special characters or spaces in last name.");
                }
            }

            if (string.IsNullOrWhiteSpace(c.LoanCompanyEmail) == false)
            {
                if (c.LoanCompanyEmail.Contains("@") == false)
                {
                    ModelState.AddModelError(nameof(c.LoanCompanyEmail), "Not a valid email address");
                }
            }
            if (ModelState.IsValid)
            {
                return(RedirectToAction("LoanAcknowledgement"));
            }
            //I tried removing c to see if the form would still remember and it did. I put c back anyways.
            return(View(c));
        }
예제 #10
0
        public async Task <IActionResult> MakeALoan(LoanViewModel loan)
        {
            Customer customer = new Customer();

            customer = await _context.customers.FirstOrDefaultAsync(c => c.FirstName == loan.ReceiverFirstName && c.LastName == loan.ReceiverLastName);

            if (customer == null)
            {
                return(NotFound());
            }
            var accounts = await _context.accounts.ToListAsync();

            bool transaction_success = false;

            foreach (var receiver_account in accounts)
            {
                if (receiver_account.Id.Equals(loan.AccountId))
                {
                    transaction_success = true;
                    receiver_account.Account_Balance += loan.AmountTaken;
                    break;
                }
            }
            if (transaction_success)
            {
                await _context.SaveChangesAsync();

                return(View("Success"));
            }
            return(View("Failed"));
        }
예제 #11
0
        public LoanViewModel UpdateReturnDate(LoanViewModel viewModel)
        {
            Loan updatedLoan;

            using (var unitOfWork = _unitOfWorkFactory
                                    .StartUnitOfWork(true))
            {
                try
                {
                    updatedLoan = _loanService.UpdateReturnDate(
                        viewModel.Id,
                        viewModel.ReturnDate.GetValueOrDefault());

                    if (updatedLoan == null)
                    {
                        unitOfWork.Rollback();
                        return(null);
                    }

                    unitOfWork.Save();
                    unitOfWork.Commit();
                }
                catch (Exception e)
                {
                    unitOfWork.Rollback();
                    return(null);
                }
            }

            return(_mapper.Map <LoanViewModel>(updatedLoan));
        }
예제 #12
0
        public async Task <IActionResult> Index(Int32?tomeId)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }
            LoanViewModel loan = _loanService.NewLoan(tomeId);

            if (loan == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (User.Identity.IsAuthenticated)
            {
                Guest guest = await _userManager.FindByNameAsync(User.Identity.Name);

                if (guest != null)
                {
                    loan.GuestEmail       = guest.Email;
                    loan.GuestName        = guest.Name;
                    loan.GuestPhoneNumber = guest.PhoneNumber;
                }
            }

            return(View("Index", loan));
        }
예제 #13
0
        public async Task <IActionResult> AddOrEdit(LoanViewModel loanView)
        {
            if (ModelState.IsValid)
            {
                if (loanView.Id == null)
                {
                    var loan = new Loan()
                    {
                        LoanCategoryId = loanView.LoanCategoryId,
                        LoanCompanyId  = loanView.LoanCompanyId,
                        InterestRate   = loanView.InterestRate,
                        MaximumAmount  = loanView.MaximumAmount,
                        MinimumAmount  = loanView.MinimumAmount,
                        Moratorium     = loanView.Moratorium,
                    };
                    await _loanRepository.AddLoan(loan);
                }

                else
                {
                    var loan = await _loanRepository.GetLoan(loanView.Id);

                    loan.LoanCompanyId  = loanView.LoanCompanyId;
                    loan.LoanCategoryId = loanView.LoanCategoryId;
                    loan.InterestRate   = loanView.InterestRate;
                    loan.MinimumAmount  = loanView.MinimumAmount;
                    loan.MaximumAmount  = loanView.MaximumAmount;
                    loan.Moratorium     = loanView.Moratorium;
                    await _loanRepository.UpdateLoan(loan);
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(loanView));
        }
예제 #14
0
        public ActionResult PageRole()
        {
            try
            {
                var    value  = "";
                string Pageid = Request.QueryString["value"];
                if (Pageid == "" || Pageid == null)
                {
                    Pageid = "2016";
                }
                GLobalClient gc = new GLobalClient();
                ViewBag.listPage = gc.findAllPages();
                //var value = 2016;
                value    = Pageid;
                pages.id = Convert.ToInt16(value);
                var pag          = "";
                var selectedItem = DataReaders.getSelectedPage(pages.id);
                if (selectedItem != null)
                {
                    pag            = selectedItem;
                    pages.PageName = pag;
                }

                var result = (from a in db.PageAuthentications
                              join c in db.Roles on a.RoleId equals c.RoleId
                              join b in db.Pags on a.PageName equals b.PageName
                              //  where b.id == pages.id
                              where b.id == pages.id
                              select new Models.GetAssignPages {
                    pageid = b.id, Roleid = c.RoleId.ToString(), Rolename = c.RoleName
                }).ToList();


                var        pageroles = DataReaders.buildPagesList(pages);
                var        roles     = DataReaders.buildAllRoleList();
                List <int> pagerole  = pageroles;
                List <int> role      = roles;
                var        newList   = roles.Except(pageroles);

                var pageurl = (from p in db.Roles
                               where newList.Contains((int)(p.RoleId))
                               select new Models.UnGetAssignRoles {
                    Roleid = p.RoleId, Rolename = p.RoleName
                }).ToList();
                var model = new LoanViewModel
                {
                    GetAssignPagess   = result.ToList(),
                    UnGetAssignRoless = pageurl.ToList(),
                };


                return(View(model));
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
 private Loan MapToModel(Loan loan, LoanViewModel model, bool isEditing)
 {
     loan.OriginalAmount  = model.OriginalAmount;
     loan.RemainingAmount = isEditing ? model.RemainingAmount : model.OriginalAmount;
     loan.MonthlyPayment  = model.MonthlyPayment;
     loan.UserID          = model.UserId;
     return(loan);
 }
예제 #16
0
        public ActionResult Edit(int Id)
        {
            GLobalClient  cc  = new GLobalClient();
            LoanViewModel cvm = new LoanViewModel();

            cvm.LoanModel = cc.find(Id);
            return(View("Edit", cvm));
        }
예제 #17
0
        public IActionResult Return(string id)
        {
            var loan = _loanService.Get(id);

            loan.ReturnedDate = DateTime.Now;

            return(View(LoanViewModel.ConvertFromDomain(loan)));
        }
예제 #18
0
        /// <summary>
        /// Return Book() - Return book from loan
        /// </summary>
        /// <param name="bookid"></param>
        /// <returns></returns>
        public async Task <(BookLoan.Models.LoanViewModel, BookLoan.Models.BookViewModel)> GetReturnLoan(int bookid)
        {
            LoanViewModel lvm = new LoanViewModel();
            BookViewModel bvm = new BookViewModel();

            BookViewModel book = new BookViewModel();

            var request = new HttpRequestMessage(HttpMethod.Get,
                                                 "http://localhost/BookLoan.Catalog.API/api/Book/List");

            var client = _clientFactory.CreateClient();

            var response = await client.SendAsync(request);

            List <BookViewModel> bookViews = new List <BookViewModel>();

            if (response.IsSuccessStatusCode)
            {
                string respContent = response.Content.ReadAsStringAsync().Result;

                JArray books = JArray.Parse(respContent) as JArray;
                foreach (var item in books)
                {
                    BookViewModel bitem = JsonConvert.DeserializeObject <BookViewModel>(item.ToString());
                    bookViews.Add(bitem);
                }
            }

            if (!bookViews.Any())
            {
                throw new Exception(String.Format("Books cannot be found."));
            }

            var bookloans = await GetBookLoans(bookid);

            if (bookloans == null)
            {
                throw new Exception(String.Format("Loans for Book {0} cannot be found.", bookid));
            }

            // Get latest loan for the book.
            foreach (LoanViewModel item in bookloans.OrderByDescending(o => o.DateLoaned))
            {
                lvm.ID          = item.ID;
                lvm.DateLoaned  = item.DateLoaned;
                lvm.DateDue     = item.DateDue;
                lvm.DateReturn  = DateTime.Now;
                lvm.DateUpdated = DateTime.Now;
                lvm.OnShelf     = false;
                lvm.LoanedBy    = "";
                lvm.BookID      = item.BookID;
                bvm.Title       = book.Title;
                bvm.Author      = book.Author;
                break;
            }

            return(lvm, bvm);
        }
예제 #19
0
        public IActionResult CreateLoan(LoanViewModel loan)
        {
            // Validate and save loan details
            // Redirect to Thank you page
            // Can trigger confirmation emails from domain service if needed
            int loanId = 0;

            return(RedirectToAction("Thankyou", new { loanId }));
        }
예제 #20
0
        public ActionResult Issue_DVD(LoanViewModel ld, int id)
        {
            Console.WriteLine("Hello there!!");

            int        mem_id     = 0;
            string     sql_member = @"select Member_ID from dbo.Member where FirstName = '" + ld.FirstName + "' AND LastName = '" + ld.LastName + "';";
            List <int> lst        = SqlDataAccess.LoadData <int>(sql_member);

            foreach (int row in lst)
            {
                mem_id = row;
                break;
            }

            string     sql_check = @"select Loan_ID from dbo.Loan where Member_ID = " + mem_id + ";";
            List <int> num       = SqlDataAccess.LoadData <int>(sql_check);

            if (num.Count > 5)
            {
                return(RedirectToAction("Limit_Exceeded", "Users"));
            }

            else
            {
                string         today = DateTime.Today.ToString("yyyy-MM-dd");
                LoanIssueModel iss   = new LoanIssueModel();
                iss.Date_out       = today;
                iss.Amount_paid    = 100;
                iss.Date_returned  = null;
                iss.Penalty_Charge = 0;
                iss.Dvd_ID         = id;
                iss.Member_ID      = mem_id;

                string             sql_member2 = @"select * from dbo.Member where Member_ID = " + mem_id + ";";
                List <MemberModel> memlist     = SqlDataAccess.LoadData <MemberModel>(sql_member2);
                MemberModel        mem         = new MemberModel();
                foreach (MemberModel row in memlist)
                {
                    mem = row;
                    break;
                }

                mem.DVD_On_Loan = mem.DVD_On_Loan + 1;
                string sql_member3 = @"UPDATE dbo.Member SET DVD_On_Loan = @DVD_On_Loan WHERE Member_ID = @Member_ID;";
                int    result1     = SqlDataAccess.SaveData(sql_member3, mem);


                string sql_loan = @"insert into dbo.Loan(Date_out, Amount_paid, Date_returned, Penalty_Charge, Dvd_ID, Member_ID)
                        values (@Date_out, @Amount_paid, @Date_returned, @Penalty_Charge, @Dvd_ID, @Member_ID);";

                int result = SqlDataAccess.SaveData(sql_loan, iss);



                return(RedirectToAction("Main", "Users"));
            }
        }
예제 #21
0
        public IActionResult SaveChanges(LoanViewModel viewModel)
        {
            var updatedLoan = _loanAppService
                              .UpdateReturnDate(viewModel);

            return(updatedLoan != null
                ? RedirectToAction("Details", viewModel)
                : RedirectToAction("Edit", new { viewModel.Id }));
        }
        public IActionResult Create(Guid id)
        {
            var loanViewModel = new LoanViewModel()
            {
                BookId = id,
            };

            return(View(loanViewModel));
        }
예제 #23
0
        public ActionResult ReturnLoan(LoanViewModel model)
        {
            var loan      = _loanInformationRepo.GetByID(model.Id);
            var component = _componentRepo.GetByID(loan.Component.Id);

            component.LoanerId = null;
            _componentRepo.SaveChanges();
            return(RedirectToAction("ShowComponents", "Component"));
        }
예제 #24
0
        public ActionResult TestUploadDocument(int loanId)
        {
            LoanViewModel loanViewModel = new LoanViewModel()
            {
                Id = loanId
            };

            return(View("_UploadDocuments", loanViewModel));
        }
예제 #25
0
        public PartialViewResult GetUploadDocumentView(int loanId)
        {
            LoanViewModel loanViewModel = new LoanViewModel()
            {
                Id = loanId
            };

            return(PartialView("_UploadDocuments", loanViewModel));
        }
예제 #26
0
        public IActionResult AfisareImprumuturi()
        {
            var loans = new LoanViewModel
            {
                IMPRUMUTs = repository.GetAllLoansAsync().Result.ToList()
            };

            return(View(loans));
        }
예제 #27
0
 public void AddLoan(LoanViewModel l)
 {
     _db.Loans.Add(new Loan {
         BookId     = l.BookId,
         UserId     = l.UserId,
         DateOfLoan = l.DateOfLoan,
         IsReturned = false
     });
     _db.SaveChanges();
 }
예제 #28
0
        public void UpdateLoanByUser(LoanViewModel updatedLoan, int user_id, int book_id)
        {
            Loan loan = (from l in _db.Loans
                         where l.UserId == user_id &&
                         l.BookId == book_id
                         select l).FirstOrDefault();

            loan.DateOfLoan = updatedLoan.DateOfLoan;
            _db.SaveChanges();
        }
예제 #29
0
        public ViewResult StudentLoan()
        {
            var vm = new LoanViewModel();

            vm.PageTitle = "Student Loan";
            vm.Loan      = new Loan {
                Amount = 600, Rate = .12M, LengthInMonths = 24
            };
            return(View(vm));
        }
        public ActionResult Create()
        {
            var viewModel = new LoanViewModel
            {
                Friends = _friendsApp.FillFriendsDropDown(),
                Games   = _gamesApp.GetAvailableGames()
            };

            return(View(viewModel));
        }