public ActionResult TenantViewPayments(int id) { //List<BGBC.Web.Models.TenantViewPayment> tenantViewPayment = new List<Models.TenantViewPayment>(); List <vRentPayment> rentpay = new List <vRentPayment>(); try { User tuser = _userRepository.Get(id); Profile profile = tuser.Profiles.FirstOrDefault(); ViewBag.Name = tuser.FirstName + " " + tuser.LastName; ViewBag.Address = profile.BillingAddress; ViewBag.State = profile.BillingState; ViewBag.City = profile.BillingCty; ViewBag.Zip = profile.BillingZip; rentpay = BGBCFunctions.RentPayments().Where(x => x.TenantUserID == id).ToList(); return(View(rentpay)); } catch (Exception ex) { log.Error(ex.Message); } return(View(new List <vRentPayment>())); }
public ActionResult ViewPayments(int id) { List <BGBC.Web.Models.AllPropertiesAndTenant> allPropertiesAndTenant = new List <Models.AllPropertiesAndTenant>(); try { Property p = _propertyRepo.Get(id); BGBC.Web.Models.AllPropertiesAndTenant propertiesTenant = new Models.AllPropertiesAndTenant(); ViewBag.PropertyID = p.PropertyID; ViewBag.Name = p.Name; ViewBag.Address = p.Address; ViewBag.Address2 = p.Address2; ViewBag.City = p.City; ViewBag.State = p.State; ViewBag.Zip = p.Zip; propertiesTenant.tenantRentPay = new List <Models.TenantRentPay>(); foreach (var t in p.Tenants) { BGBC.Web.Models.TenantRentPay tenantRentPay = new BGBC.Web.Models.TenantRentPay(); tenantRentPay.tname = t.User.FirstName; tenantRentPay.RentPayment = BGBCFunctions.RentPayments().Where(x => x.TenantUserID == t.User.UserID).ToList(); propertiesTenant.tenantRentPay.Add(tenantRentPay); } allPropertiesAndTenant.Add(propertiesTenant); } catch (Exception ex) { log.Error(ex.Message); } return(View(allPropertiesAndTenant)); }
public ActionResult PropertyTenants(int id) { //Mohan code change is required to get property by owner id Property pro = _propertyRepo.Get(id); ViewBag.PropertyID = id; ViewBag.PropertyName = pro.Name; return(View(BGBCFunctions.TenantOutstanding(id))); }
public ActionResult PropertyTenants(int id) { Property pro = _propertyRepo.Get(id); ViewBag.PropertyID = id; ViewBag.PropertyName = pro.Name; ViewBag.UserId = pro.UserID; //User userid = _propertyRepo.Get().Where(x => x.UserID == id); //ViewBag.UserId = userid; return(View(BGBCFunctions.TenantOutstanding(id))); }
public ActionResult OrderHistory(int?id) { List <vProductOrder> payment = new List <vProductOrder>(); try { payment = BGBCFunctions.ProductOrders().Where(x => x.UserID == ((BGBC.Core.CustomPrincipal)(User)).UserId).OrderByDescending(o => o.TransDate).ToList(); } catch (Exception ex) { log.Error(ex.Message); } return(View(payment)); }
public ActionResult ViewPropertyPayment(int id) { List <vRentPayment> rentpay = new List <vRentPayment>(); try { // User user = _userRepository.Get(((BGBC.Core.CustomPrincipal)(User)).UserId); Property property = _propertyRepo.Get(id); ViewBag.PropertyID = property.PropertyID; ViewBag.Name = property.Name; rentpay = BGBCFunctions.RentPayments().Where(x => x.PropertyID == id).OrderByDescending(o => o.TransDate).ToList(); } catch (Exception ex) { log.Error(ex.Message); } return(View(rentpay)); }
public ActionResult ViewTenantsPayment(int id) { List <vRentPayment> rentpay = new List <vRentPayment>(); try { User tuser = _userRepository.Get(id); Profile profile = tuser.Profiles.FirstOrDefault(); ViewBag.Name = tuser.FirstName + " " + tuser.LastName; rentpay = BGBCFunctions.RentPayments().Where(x => x.TenantUserID == id).ToList(); return(View(rentpay)); } catch (Exception ex) { log.Error(ex.Message); } return(View(new List <vRentPayment>())); }
public ActionResult TenantPaymentHistory(int?id) { IEnumerable <vRentPayment> paymentdetails = new List <vRentPayment>(); try { paymentdetails = BGBCFunctions.RentPayments() .Where(x => x.TenantUserID == (id == null ? ((BGBC.Core.CustomPrincipal)(User)).UserId : id)) .OrderByDescending(d => d.TransDate).ToList(); Tenant tenants = _tenantRepo.Get().Where(x => x.UserID == (id == null ? ((BGBC.Core.CustomPrincipal)(User)).UserId : id)).FirstOrDefault(); ViewBag.Propertyname = (tenants != null ? tenants.Property.Name : ""); } catch (Exception ex) { log.Error(ex.Message); } return(View(paymentdetails)); }
public ActionResult ProductInvoice(int id) { IEnumerable <ProductOrder> productOrderList = new List <ProductOrder>(); try { Order order = _order.Get(id); ViewBag.TransactionNo = order.TransId; ViewBag.Date = order.TransDate; ViewBag.BillAddress = order.BillAddress; ViewBag.Customer = order.User.FirstName + " " + order.User.LastName; productOrderList = BGBCFunctions.ProductOrderIds().Where(x => x.OrderID == id).ToList(); } catch (Exception ex) { log.Error(ex.Message); } return(View(productOrderList)); }
public ActionResult PropertyPaymentsHistory(int id) { List <vRentPayment> rentpay = new List <vRentPayment>(); try { User user = _userRepository.Get(((BGBC.Core.CustomPrincipal)(User)).UserId); Property property = _propertyRepo.Get((int)user.Properties.FirstOrDefault().PropertyID); ViewBag.Address = property.Address; ViewBag.Address2 = property.Address2; ViewBag.City = property.City; ViewBag.State = property.State; ViewBag.Zip = property.Zip; rentpay = BGBCFunctions.RentPayments().Where(x => x.PropertyID == id).ToList(); } catch (Exception ex) { log.Error(ex.Message); } return(View(rentpay)); }
public ActionResult AllPropertiesAndTenant() { List <BGBC.Web.Models.AllPropertiesAndTenant> allPropertiesAndTenant = new List <Models.AllPropertiesAndTenant>(); List <Property> property = _pro.GetRef(((BGBC.Core.CustomPrincipal)(User)).UserId); foreach (var p in property) { BGBC.Web.Models.AllPropertiesAndTenant allProps = new Models.AllPropertiesAndTenant(); allProps.Pname = p.Name; allProps.tenantRentPay = new List <Models.TenantRentPay>(); foreach (var t in p.Tenants) { BGBC.Web.Models.TenantRentPay tRentPay = new BGBC.Web.Models.TenantRentPay(); tRentPay.tname = t.User.FirstName + " " + t.User.LastName; tRentPay.RentPayment = BGBCFunctions.RentPayments().Where(x => x.TenantUserID == t.User.UserID).OrderByDescending(d => d.TransDate).Take(5).ToList(); allProps.tenantRentPay.Add(tRentPay); } allPropertiesAndTenant.Add(allProps); } return(View(allPropertiesAndTenant)); }
public ActionResult AllProductsOrders(int?id, string sortOrder, string currentFilter, string searchString, int?page, string PageSize) { if (id != null) { Product product = _product.Get(id); ViewBag.Name = product.Name; } int currentPageSize = int.Parse(PageSize == null ? "10" : PageSize), pageNumber = (page ?? 1); try { var products = (id == null ? BGBCFunctions.ProductOrders() : BGBCFunctions.ProductOrders().Where(x => x.ProductID == id)); ViewBag.CurrentSort = sortOrder; ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date"; ViewBag.TransIDSortParm = sortOrder == "TransID" ? "TransID_desc" : "TransID"; ViewBag.CustomerSortParm = sortOrder == "Customer" ? "Customer_desc" : "Customer"; ViewBag.TypeSortParm = sortOrder == "Type" ? "Type_desc" : "Type"; ViewBag.PriceSortParm = sortOrder == "Price" ? "Price_desc" : "Price"; ViewBag.NameSortParm = sortOrder == "Name" ? "name_desc" : "Name"; ViewBag.CommentsSortParm = sortOrder == "Comments" ? "comments_desc" : "Comments"; if (PageSize != null) { ViewBag.currentPageSize = currentPageSize; } if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; ViewBag.page = pageNumber; if (!string.IsNullOrEmpty(searchString)) { products = products.Where(x => x.CustomerFName.Contains(searchString) || x.CustomerLName.Contains(searchString) || x.Name.Contains(searchString) || x.TransId.Contains(searchString)); } switch (sortOrder) { case "date_desc": products = products.OrderByDescending(x => x.TransDate); break; case "TransID": products = products.OrderBy(x => x.TransId); break; case "TransID_desc": products = products.OrderByDescending(x => x.TransId); break; case "Customer": products = products.OrderBy(x => x.CustomerFName); break; case "Customer_desc": products = products.OrderByDescending(x => x.CustomerFName); break; case "Type": products = products.OrderBy(x => x.UserType); break; case "Type_desc": products = products.OrderByDescending(x => x.UserType); break; case "Name": products = products.OrderBy(x => x.Name); break; case "name_desc": products = products.OrderByDescending(x => x.Name); break; case "Price": products = products.OrderBy(x => x.Price); break; case "Price_desc": products = products.OrderByDescending(x => x.Price); break; case "Comments": products = products.OrderBy(x => x.Comments); break; case "comments_desc": products = products.OrderByDescending(x => x.Comments); break; default: // Date ascending products = products.OrderBy(x => x.TransDate); break; } return(View(products.ToPagedList(pageNumber, currentPageSize))); } catch (Exception ex) { log.Error(ex.Message); } return(View()); }
static void Main(string[] args) { //Call Rent calculation SP log4net.ILog log = log4net.LogManager.GetLogger(typeof(BGBC.Schedule.Program)); try { BGBC.Model.BGBCFunctions.RentCalcSchedule(DateTime.Today.Date); log.Info("Executed for " + DateTime.Today.Date); } catch (Exception ex) { log.Error(ex.Message); } IRepository <RentAutoPay, int> rentAutoRepo = new RentAutoPayRepository(); IRepository <RentDue, int?> rentDueRepo = new RentDueRepository(); try { IEnumerable <RentAutoPay> listRentPay = listRentPay = rentAutoRepo.Get(); foreach (var rentPayitem in listRentPay) { RentDue rentDue = rentDueRepo.Get().Where(x => x.UserID == rentPayitem.UserID && x.DueStatus == true).FirstOrDefault(); if (rentDue != null) { try { User user = rentDue.User; Profile profile = rentDue.User.Profiles.FirstOrDefault(); var lineItems = new AuthorizeNet.Api.Contracts.V1.lineItemType[2]; int[] rentidsarry = new int[2]; string fee = "Service Fee(10.75%)"; lineItems[0] = new AuthorizeNet.Api.Contracts.V1.lineItemType { itemId = "1", name = (rentDue.Description.Length < 30) ? rentDue.Description : rentDue.Description.Substring(0, 30), quantity = 1, unitPrice = rentDue.DueAmount }; lineItems[1] = new AuthorizeNet.Api.Contracts.V1.lineItemType { itemId = "1", name = (fee.Length < 30) ? fee : fee.Substring(0, 30), quantity = 1, unitPrice = rentPayitem.Charges }; int invoiceNumber = BGBCFunctions.GetInoiveNo(); AuthorizeNet.Api.Controllers.createTransactionController controller; var billAddress = new AuthorizeNet.Api.Contracts.V1.customerAddressType { firstName = user.FirstName, lastName = user.LastName, address = profile.BillingAddress + ", " + (string.IsNullOrEmpty(profile.BillingAddress_2) ? "" : profile.BillingAddress_2), city = profile.BillingCty, state = profile.BillingState, zip = profile.BillingZip, email = user.Email, phoneNumber = profile.MobilePhone, country = "USA" }; string address = string.Format("{0}<br/>{1}<br/>{2}, {3} {4}", profile.BillingAddress, profile.BillingAddress_2, profile.BillingCty, profile.BillingState, profile.BillingZip); if (rentPayitem.PaymentType == 2) { var bankAccount = new AuthorizeNet.Api.Contracts.V1.bankAccountType { accountNumber = rentPayitem.AccountNo, routingNumber = rentPayitem.RoutingNo, echeckType = AuthorizeNet.Api.Contracts.V1.echeckTypeEnum.WEB, // change based on how you take the payment (web, telephone, etc) nameOnAccount = user.FirstName + " " + user.LastName }; controller = PaymentGateway.DebitBankAccount(bankAccount, lineItems, billAddress, rentPayitem.TotalAmt, invoiceNumber); } else { var creditCard = new AuthorizeNet.Api.Contracts.V1.creditCardType { cardNumber = rentPayitem.CCNO, expirationDate = rentPayitem.ExpMon + rentPayitem.ExpYear.ToString(), cardCode = rentPayitem.CVV }; controller = PaymentGateway.ChargeCreditCard(creditCard, lineItems, billAddress, rentPayitem.TotalAmt, invoiceNumber); } AuthorizeNet.Api.Contracts.V1.createTransactionResponse response = controller.GetApiResponse(); if (response != null) { if (response.messages.resultCode == AuthorizeNet.Api.Contracts.V1.messageTypeEnum.Ok) { if (response.transactionResponse != null) { if (response.transactionResponse.errors == null) { try { string rentid = string.Join(",", rentidsarry); Payment pay = BGBCFunctions.RentPayment(user.UserID, invoiceNumber, response.transactionResponse.accountNumber, response.transactionResponse.accountType, response.transactionResponse.transId, response.transactionResponse.messages[0].code, response.transactionResponse.messages[0].description, "", rentPayitem.TotalAmt, address, "Auto rent pay", rentDue.RentDueID.ToString()); IRepository <RentPayment, int> rentPay = new RentPaymentRepository(); rentPay.Add(new RentPayment { PropertyID = rentDue.PropertyID, Description = fee, Amount = rentPayitem.Charges, PaymentID = pay.PaymentID }); } catch (Exception ex) { Console.WriteLine("Transaction Error : " + ex.Message); } System.Diagnostics.Trace.TraceInformation("Success, Auth Code : " + response.transactionResponse.authCode); } else { Console.WriteLine("Transaction Error : " + response.transactionResponse.errors[0].errorCode + " " + response.transactionResponse.errors[0].errorText); } } } else { System.Diagnostics.Trace.TraceInformation("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); if (response.transactionResponse != null) { Console.WriteLine("Transaction Error : " + response.transactionResponse.errors[0].errorCode + " " + response.transactionResponse.errors[0].errorText); } } } else { Console.WriteLine("Transaction Error, unable to complete the transaction."); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine("Transaction Error, unable to complete the transaction."); } } } } catch (Exception ex) { throw; } }
public ActionResult ViewOrders(int id) { return(View(BGBCFunctions.ProductOrders().Where(x => x.ProductID == id).OrderByDescending(s => s.TransDate).ToList())); }
public ActionResult Transaction() { Models.Checkout checkout = new Models.Checkout(); try { checkout = (Models.Checkout)TempData["cartdata"]; var lineItems = new AuthorizeNet.Api.Contracts.V1.lineItemType[checkout.OrderList.Count]; for (int i = 0; i < checkout.OrderList.Count; i++) { lineItems[i] = new AuthorizeNet.Api.Contracts.V1.lineItemType { itemId = i.ToString(), name = (checkout.OrderList[i].Item.Length < 10) ? checkout.OrderList[i].Item : checkout.OrderList[i].Item.Substring(0, 10), quantity = checkout.OrderList[i].Quantity, unitPrice = checkout.OrderList[i].Subtotal }; } int invoiceNumber = BGBCFunctions.GetInoiveNo(); AuthorizeNet.Api.Controllers.createTransactionController controller; var billAddress = new AuthorizeNet.Api.Contracts.V1.customerAddressType { firstName = checkout.FirstName, lastName = checkout.LastName, address = checkout.BillingAddress + ", " + (string.IsNullOrEmpty(checkout.BillingAddress_2) ? "" : checkout.BillingAddress_2), city = checkout.BillingCty, state = checkout.BillingState, zip = checkout.BillingZip, email = checkout.Email, phoneNumber = checkout.Phone, country = "USA" }; string address = string.Format("{0}<br/>{1}<br/>{2}, {3} {4}", checkout.BillingAddress, checkout.BillingAddress_2, checkout.BillingCty, checkout.BillingState, checkout.BillingZip); if (checkout.PaymentMethod == "eCheck") { var bankAccount = new AuthorizeNet.Api.Contracts.V1.bankAccountType { accountNumber = checkout.BankAccountNumber, routingNumber = checkout.BankRoutingNumber, echeckType = AuthorizeNet.Api.Contracts.V1.echeckTypeEnum.WEB, // change based on how you take the payment (web, telephone, etc) nameOnAccount = checkout.FirstName + " " + checkout.LastName }; controller = PaymentGateway.DebitBankAccount(bankAccount, lineItems, billAddress, checkout.OrderTotal, invoiceNumber); } else { var creditCard = new AuthorizeNet.Api.Contracts.V1.creditCardType { cardNumber = checkout.CardNo, expirationDate = checkout.CardExpMon + checkout.CardExpYear.ToString(), cardCode = checkout.CVV }; controller = PaymentGateway.ChargeCreditCard(creditCard, lineItems, billAddress, checkout.OrderTotal, invoiceNumber); } AuthorizeNet.Api.Contracts.V1.createTransactionResponse response = controller.GetApiResponse(); if (response != null) { if (response.messages.resultCode == AuthorizeNet.Api.Contracts.V1.messageTypeEnum.Ok) { if (response.transactionResponse != null) { if (response.transactionResponse.errors == null) { try { int userid = 0; if (!Request.IsAuthenticated) { User selUser = new User { FirstName = checkout.FirstName, LastName = checkout.LastName, Password = BGBC.Core.Security.Cryptography.Encrypt(checkout.ChoosePassword), UserType = 3, Email = checkout.Email }; selUser.Profiles.Add(new Profile { BillingAddress = checkout.BillingAddress, BillingAddress_2 = checkout.BillingAddress_2, BillingCty = checkout.BillingCty, BillingState = checkout.BillingState, MobilePhone = checkout.Phone }); selUser = _userRepository.Add(selUser); CustomPrincipalSerializeModel serializeModel = new CustomPrincipalSerializeModel(); serializeModel.UserId = selUser.UserID; serializeModel.FirstName = selUser.FirstName; serializeModel.LastName = selUser.LastName; serializeModel.roles = new string[] { "Customer" }; string userData = Newtonsoft.Json.JsonConvert.SerializeObject(serializeModel); System.Web.Security.FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, selUser.FirstName, DateTime.Now, DateTime.Now.AddMinutes(15), false, userData); string encTicket = FormsAuthentication.Encrypt(authTicket); HttpCookie faCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket); Response.Cookies.Add(faCookie); userid = selUser.UserID; } else { userid = ((BGBC.Core.CustomPrincipal)(User)).UserId; } Order order = BGBCFunctions.ProductTrans(userid, checkout.Email, checkout.ChoosePassword, invoiceNumber, response.transactionResponse.accountNumber, response.transactionResponse.accountType, response.transactionResponse.transId, response.transactionResponse.messages[0].code, response.transactionResponse.messages[0].description, Request.UserHostAddress, address, checkout.Comments, checkout.ProductIds); IRepository <ProductOrder, int> productOrder = new ProductOrderRepository(); foreach (var item in checkout.OrderList.Where(x => x.ProductID == 0)) { productOrder.Add(new ProductOrder { OrderID = order.OrderID, Name = item.Item, Price = item.Price }); } //Save Payment details if (checkout.SaveCard) { UserCC ccinfo = _userCCRep.Get(userid); if (ccinfo == null) //There is no details in database { if (checkout.PaymentMethod == "eCheck") { _userCCRep.Add(new UserCC { UserID = userid, PaymentType = 2, AccountType = checkout.BankAccountType, RoutingNo = Cryptography.Encrypt(checkout.BankRoutingNumber), AccountNo = Cryptography.Encrypt(checkout.BankAccountNumber) }); } else { _userCCRep.Add(new UserCC { UserID = userid, PaymentType = 1, CCNO = Cryptography.Encrypt(checkout.CardNo), ExpMon = Cryptography.Encrypt(checkout.CardExpMon), ExpYear = Cryptography.Encrypt(checkout.CardExpYear) }); } } else { if (checkout.PaymentMethod == "eCheck") { ccinfo.CCNO = string.Empty; ccinfo.ExpMon = string.Empty; ccinfo.ExpYear = string.Empty; ccinfo.PaymentType = 2; ccinfo.AccountType = checkout.BankAccountType; ccinfo.RoutingNo = Cryptography.Encrypt(checkout.BankRoutingNumber); ccinfo.AccountNo = Cryptography.Encrypt(checkout.BankAccountNumber); } else { ccinfo.CCNO = Cryptography.Encrypt(checkout.CardNo); ccinfo.ExpMon = Cryptography.Encrypt(checkout.CardExpMon); ccinfo.ExpYear = Cryptography.Encrypt(checkout.CardExpYear); ccinfo.PaymentType = 1; ccinfo.AccountType = string.Empty; ccinfo.RoutingNo = string.Empty; ccinfo.AccountNo = string.Empty; } } } else { UserCC ccinfo = _userCCRep.Get(userid); if (ccinfo != null) { _userCCRep.Remove(ccinfo); } } HttpCookie authCookie = Request.Cookies[".BGBCProducts"]; authCookie.Value = string.Empty; Response.SetCookie(authCookie); TempData.Remove("cartdata"); return(RedirectToAction("OrderHistory", "Report")); } catch (Exception ex) { log.Error(ex.Message); ModelState.AddModelError("", "Transaction Error : " + ex.Message); } System.Diagnostics.Trace.TraceInformation("Success, Auth Code : " + response.transactionResponse.authCode); } else { ModelState.AddModelError("", "Transaction Error : " + response.transactionResponse.errors[0].errorCode + " " + response.transactionResponse.errors[0].errorText); } } } else { System.Diagnostics.Trace.TraceInformation("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); if (response.transactionResponse != null) { ModelState.AddModelError("", "Transaction Error : " + response.transactionResponse.errors[0].errorCode + " " + response.transactionResponse.errors[0].errorText); } TempData["cartdata"] = checkout; } } else { TempData["cartdata"] = checkout; ModelState.AddModelError("", "Transaction Error, unable to complete the transaction."); } } catch (Exception ex) { log.Error(ex.Message); ModelState.AddModelError("", "Transaction Error, unable to complete the transaction."); } Tuple <List <Models.OrderSummary>, decimal, string> ordersummary = getCartProducts(); checkout.OrderList = ordersummary.Item1; checkout.OrderTotal = ordersummary.Item2; checkout.ProductIds = ordersummary.Item3; checkoutDropDown(); return(View("Checkout", checkout)); }
public ActionResult PaymentHistory(string sortOrder, string currentFilter, string searchString, int?page, string pageSize, string searchOwner) { int currentPageSize = int.Parse(pageSize == null ? "10" : pageSize), pageNumber = (page ?? 1); try { var rentPayments = BGBCFunctions.RentPayments(); ViewBag.currentSort = sortOrder; ViewBag.dateSortParam = sortOrder == "date" ? "date_desc" : "date"; ViewBag.idSortParam = sortOrder == "id" ? "id_desc" : "id"; ViewBag.nameSortParam = sortOrder == "name" ? "name_desc" : "name"; ViewBag.ownerSortParam = sortOrder == "owner" ? "owner_desc" : "owner"; ViewBag.descSortParam = sortOrder == "desc" ? "desc_desc" : "desc"; ViewBag.amountSortParam = sortOrder == "amount" ? "amount_desc" : "amount"; ViewBag.commentSortParam = sortOrder == "comment" ? "comment_desc" : "comment"; if (pageSize != null) { ViewBag.currentPageSize = currentPageSize; } if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.currentFilter = searchString; ViewBag.page = pageNumber; if (!string.IsNullOrEmpty(searchString)) { rentPayments = rentPayments.Where(x => x.TenantLastName.Contains(searchString) || x.TenantFirstName.Contains(searchString) || x.OwnerFirstName.Contains(searchString) || x.OwnerLastName.Contains(searchString) || x.TransID.Contains(searchString)); // || x.Amount.Equals(searchString)|| x.TransDate.Equals(searchString)); } if (!string.IsNullOrEmpty(searchOwner)) { rentPayments = rentPayments.Where(x => x.OwnerFirstName.Contains(searchOwner)); ViewBag.currentFilterForDropdown = searchOwner; } switch (sortOrder) { case "date_desc": rentPayments = rentPayments.OrderByDescending(x => x.TransDate); break; case "id": rentPayments = rentPayments.OrderBy(x => x.ID); break; case "id_desc": rentPayments = rentPayments.OrderByDescending(x => x.ID); break; case "name": rentPayments = rentPayments.OrderBy(x => x.TenantFirstName); break; case "name_desc": rentPayments = rentPayments.OrderByDescending(x => x.TenantFirstName); break; case "owner": rentPayments = rentPayments.OrderBy(x => x.OwnerFirstName); break; case "owner_desc": rentPayments = rentPayments.OrderByDescending(x => x.OwnerFirstName); break; case "desc": rentPayments = rentPayments.OrderBy(x => x.Description); break; case "desc_desc": rentPayments = rentPayments.OrderByDescending(x => x.Description); break; case "amount": rentPayments = rentPayments.OrderBy(x => x.Amount); break; case "amount_desc": rentPayments = rentPayments.OrderByDescending(x => x.Amount); break; case "comment": rentPayments = rentPayments.OrderBy(x => x.Comments); break; case "comment_desc": rentPayments = rentPayments.OrderByDescending(x => x.Comments); break; default: rentPayments = rentPayments.OrderBy(x => x.TransDate); break; } PropagateOwnerDropdown(ViewBag.currentFilterForDropdown); return(View(rentPayments.ToPagedList(pageNumber, currentPageSize))); } catch (Exception ex) { log.Error(ex.Message); } return(View(new List <vRentPayment>())); }
public ActionResult Mails(int?id, string sortOrder, string currentFilter, string searchString, int?page, string PageSize, DateTime?fromdate, DateTime?todate) { int currentPageSize = int.Parse(PageSize == null ? "10" : PageSize), pageNumber = (page ?? 1); try { var emails = (id == null ? BGBCFunctions.EmailDates() : BGBCFunctions.EmailDates().Where(x => x.EmailID == id)); if (PageSize != null) { ViewBag.currentPageSize = currentPageSize; } ViewBag.CurrentSort = sortOrder; ViewBag.toSortParm = sortOrder == "To_Address" ? "to_desc" : "To_Address"; ViewBag.subSortParm = sortOrder == "Subject" ? "sub_desc" : "Subject"; ViewBag.bodySortParm = sortOrder == "Body" ? "body_desc" : "Body"; ViewBag.dateSortParm = sortOrder == "Mail_Date" ? "date_desc" : "Mail_Date"; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; ViewBag.page = pageNumber; if (fromdate != null) { ViewBag.fromdate = fromdate; ViewBag.todate = todate; } if (fromdate.HasValue) { emails = emails.Where(x => x.Createdon >= fromdate); } if (todate.HasValue) { var finaldate = Convert.ToDateTime(todate).AddDays(1); emails = emails.Where(x => x.Createdon <= finaldate); } if (!string.IsNullOrEmpty(searchString)) { emails = emails.Where(x => x.ToAddress.Contains(searchString) || x.Subject.Contains(searchString)); } switch (sortOrder) { case "to_desc": emails = emails.OrderBy(x => x.ToAddress); break; case "sub_desc": emails = emails.OrderBy(x => x.Subject); break; case "body_desc": emails = emails.OrderBy(x => x.Body); break; case "date_desc": emails = emails.OrderBy(x => x.Createdon); break; default: emails = emails.OrderBy(x => x.Createdon); break; } return(View(emails.ToPagedList(pageNumber, currentPageSize))); } catch (Exception ex) { log.Error(ex.Message); } return(View()); }