public List <BillModelView> GetBills() { //get credential CredentialModel credential = HttpContext.Session.GetObject <CredentialModel>(Constants.VM); // get profile UserProfile profile = GetApiUserProfile.GetUserProfiles().SingleOrDefault(p => p.UserProfileEmail == credential.AccountUserName); // get all Bill with profileID from server List <BillModelView> bills = GetApiMyBills.GetBills(credential).Select(p => new BillModelView() { BillId = p.BillId, BillCode = p.GenerateCodeCheck, DateOfPurchase = p.DateOfPurchase, DateDelivery = Convert.ToDateTime(p.DateOfDelivered), TotalPrice = p.TotalPrice, PaymentMethodId = p.PaymentMethodTypeId, IsDelivery = p.IsDelivery, IsCancel = p.IsCancel, }).ToList(); // get payment method foreach (var bill in bills) { bill.PaymentMethodName = GetApiPaymentMethodTypes.GetPaymentMethodTypes().SingleOrDefault(p => p.PaymentMethodTypeId == bill.PaymentMethodId).PaymentMethodTypeName; } // get bill detail foreach (var item in bills) { List <BillDetailModel> details = GetApiBillDetails.GetBillDetails().Where(p => p.BillId == item.BillId) .Select(p => new BillDetailModel() { ProductId = p.ProductId, ProductName = GetApiProducts.GetProducts().SingleOrDefault(k => k.ProductId == p.ProductId).ProductName, Amount = p.ProductAmount, Price = p.ProductPriceCurrent, NoteSize = p.NoteSize, Image = GetApiProducts.GetProducts().SingleOrDefault(k => k.ProductId == p.ProductId).ProductImage, }).ToList(); item.BillDetail = details; // get delivery of bill DeliveryProduct delivery = GetApiDeliveryProducts.GetDeliveryProducts().SingleOrDefault(p => p.DeliveryProductBillId == item.BillId); // get state of bill item.DeliveryProductStateId = delivery.DeliveryProductStateId; item.DeliveryStateName = GetApiDeliveryStates.GetDeliveryProductStates().SingleOrDefault(p => p.DeliveryProductStateId == delivery.DeliveryProductStateId).DeliveryProductStateName; } return(bills); }
public IActionResult PaymentMethodFilter(string from = "nodata", string to = "nodata") { DateTime fromValue = new DateTime(); DateTime toValue = new DateTime(); if (from == "nodata" && to == "nodata") { fromValue = DateTime.Now.AddDays(-6); toValue = DateTime.Now; } else if (from == "nodata" && to != "nodata") { fromValue = DateTime.Parse(to).AddDays(-6); toValue = DateTime.Parse(to); } else if (from != "nodata" && to == "nodata") { fromValue = DateTime.Parse(from); toValue = DateTime.Parse(from).AddDays(6); } else { fromValue = DateTime.Parse(from); toValue = DateTime.Parse(to); } List <Earning7Day> paymentMethod7Days = new List <Earning7Day>(); CredentialManage credential = JsonConvert.DeserializeObject <CredentialManage>(HttpContext.Session.GetString(Constants.VM_MANAGE)); List <string> paymentMethod = new List <string>(); foreach (var p in GetApiPaymentMethodTypes.GetPaymentMethodTypes()) { paymentMethod.Add(p.PaymentMethodTypeName); } // get data foreach (var payment in paymentMethod) { paymentMethod7Days.Add(new Earning7Day() { Label = payment, Data = GetBills(credential).Where(p => p.PaymentMethodTypeId == GetApiPaymentMethodTypes.GetPaymentMethodTypes().SingleOrDefault(k => k.PaymentMethodTypeName == payment).PaymentMethodTypeId&& (p.DateOfPurchase.Date >= fromValue.Date) && (p.DateOfPurchase.Date <= toValue.Date)).Count() }); } return(Json(paymentMethod7Days.OrderBy(p => p.Label).ToList())); }
public IActionResult BillDetail(int billId) { CredentialManage credential = JsonConvert.DeserializeObject <CredentialManage>(HttpContext.Session.GetString(Constants.VM_MANAGE)); Bill p = GetApiBills.GetBills(credential).SingleOrDefault(p => p.BillId == billId); BillModelView bill = new BillModelView() { BillId = p.BillId, BillCode = p.GenerateCodeCheck, DateOfPurchase = p.DateOfPurchase, DateDelivery = Convert.ToDateTime(p.DateOfDelivered), TotalPrice = p.TotalPrice, PaymentMethodId = p.PaymentMethodTypeId, IsDelivery = p.IsDelivery, IsCancel = p.IsCancel, IsApprove = p.IsApprove, IsCompleted = p.IsCompleted, PaymentMethodName = GetApiPaymentMethodTypes.GetPaymentMethodTypes().SingleOrDefault(k => k.PaymentMethodTypeId == p.PaymentMethodTypeId).PaymentMethodTypeName, }; List <BillDetailModel> details = GetApiBillDetails.GetBillDetails().Where(p => p.BillId == bill.BillId) .Select(p => new BillDetailModel() { ProductId = p.ProductId, ProductName = GetApiProducts.GetProducts().SingleOrDefault(k => k.ProductId == p.ProductId).ProductName, Amount = p.ProductAmount, Price = p.ProductPriceCurrent, NoteSize = p.NoteSize, Image = GetApiProducts.GetProducts().SingleOrDefault(k => k.ProductId == p.ProductId).ProductImage, }).ToList(); bill.BillDetail = details; // get delivery DeliveryProduct delivery = GetApiDeliveryProducts.GetDeliveryProducts().SingleOrDefault(p => p.DeliveryProductBillId == bill.BillId); bill.delivery = delivery; // get state of bill bill.DeliveryProductStateId = delivery.DeliveryProductStateId; bill.DeliveryStateName = GetApiDeliveryStates.GetDeliveryProductStates().SingleOrDefault(p => p.DeliveryProductStateId == delivery.DeliveryProductStateId).DeliveryProductStateName; return(Json(bill)); }
public IActionResult PaymentMethod7Days(int days) { List <Earning7Day> paymentMethod7Days = new List <Earning7Day>(); CredentialManage credential = JsonConvert.DeserializeObject <CredentialManage>(HttpContext.Session.GetString(Constants.VM_MANAGE)); List <string> paymentMethod = new List <string>(); foreach (var p in GetApiPaymentMethodTypes.GetPaymentMethodTypes()) { paymentMethod.Add(p.PaymentMethodTypeName); } // get data foreach (var payment in paymentMethod) { paymentMethod7Days.Add(new Earning7Day() { Label = payment, Data = GetBills(credential).Where(p => p.PaymentMethodTypeId == GetApiPaymentMethodTypes.GetPaymentMethodTypes().SingleOrDefault(k => k.PaymentMethodTypeName == payment).PaymentMethodTypeId&& (DateTime.Now.Date - p.DateOfPurchase.Date).Days < days).Count() }); } return(Json(paymentMethod7Days.OrderBy(p => p.Label).ToList())); }
public List <BillViewModel> getBills() { CredentialManage credential = JsonConvert.DeserializeObject <CredentialManage>(HttpContext.Session.GetString(Constants.VM_MANAGE)); List <BillViewModel> bills = GetApiBills.GetBills(credential).Select(p => new BillViewModel() { BillId = p.BillId, UserProfileEmail = GetApiUserProfile.GetUserProfiles().SingleOrDefault(k => k.UserProfileId == p.UserProfileId).UserProfileEmail, DateOfPurchase = p.DateOfPurchase, CurrentDeliveryState = GetApiDeliveryStates.GetDeliveryProductStates().SingleOrDefault(h => h.DeliveryProductStateId == GetApiDeliveryProducts.GetDeliveryProducts().SingleOrDefault(k => k.DeliveryProductBillId == p.BillId).DeliveryProductStateId).DeliveryProductStateName, IsDelivery = p.IsDelivery, DateOfDelivered = p.DateOfDelivered, GenerateCodeCheck = p.GenerateCodeCheck, PaymentMethodName = GetApiPaymentMethodTypes.GetPaymentMethodTypes().SingleOrDefault(k => k.PaymentMethodTypeId == p.PaymentMethodTypeId).PaymentMethodTypeName, IsCancel = p.IsCancel, TotalPrice = p.TotalPrice, IsApprove = p.IsApprove, IsCompleted = p.IsCompleted, CurrentDeliveryStateId = GetApiDeliveryProducts.GetDeliveryProducts().SingleOrDefault(k => k.DeliveryProductBillId == p.BillId).DeliveryProductStateId }).ToList(); return(bills); }