protected SecurityPriceModel GetModelByModelFields(SecurityPriceModel modelWithValue) { return(_securitypriceRepository.GetAll(w => w.IsDeleted == false && w.Security.IsDeleted == false).Where(Createfilter <SecurityPrice>(modelWithValue)) .Select(s => new SecurityPriceModel { Id = s.Id, SecurityId = s.SecurityId, SecurityCode = s.Security.Code, SecurityName = s.Security.Name, Date = s.Date, CurrencyId = s.CurrencyId, Currency = s.Currency.Code ?? s.Security.Currency.Code, UnitPrice = s.UnitPrice, PriceNAV = s.PriceNAV, PricePUR = s.PricePUR, InterestRate = s.InterestRate, ValuationTypeId = s.ValuationTypeId, Valuer = s.Valuer, Attachment = s.Attachment, IsDeleted = s.IsDeleted, FName = s.NAVSecurityAttachments.FirstOrDefault().Attachment.FileName, Extension = s.NAVSecurityAttachments.FirstOrDefault().Attachment.Extension.HasValue ? s.NAVSecurityAttachments.FirstOrDefault().Attachment.Extension.Value : 0, }).FirstOrDefault()); }
protected List <SecurityPriceModel> GetModelListByModelFieldsDateRange(SecurityPriceModel modelWithValue) { IQueryable <SecurityPrice> spList; if (modelWithValue.SecurityId == 0 && (modelWithValue.FromDate == null || modelWithValue.ToDate == null)) { spList = _securitypriceRepository.GetAll(w => w.IsDeleted == false && w.Security.IsDeleted == false); } else if (modelWithValue.SecurityId == 0) { spList = _securitypriceRepository.GetAll(w => w.IsDeleted == false && w.Security.IsDeleted == false).Where(s => s.Date >= modelWithValue.FromDate && s.Date <= modelWithValue.ToDate); } else if (modelWithValue.FromDate == null || modelWithValue.ToDate == null) { spList = _securitypriceRepository.GetAll(w => w.IsDeleted == false && w.Security.IsDeleted == false).Where(Createfilter <SecurityPrice>(modelWithValue)); } else { spList = _securitypriceRepository.GetAll(w => w.IsDeleted == false && w.Security.IsDeleted == false).Where(Createfilter <SecurityPrice>(modelWithValue)).Where(s => s.Date >= modelWithValue.FromDate && s.Date <= modelWithValue.ToDate); } if (modelWithValue.IsRateIndex) { spList = spList.Where(s => s.Security.Unitised.Unitised1 == "Rate"); } else { spList = spList.Where(s => s.Security.Unitised.Unitised1 != "Rate"); } return(spList.Select(s => new SecurityPriceModel { Id = s.Id, SecurityId = s.SecurityId, SecurityCode = s.Security.Code, SecurityName = s.Security.Name, Date = s.Date, CurrencyId = s.CurrencyId, Currency = s.Currency.Code ?? s.Security.Currency.Code, UnitPrice = s.UnitPrice, PriceNAV = s.PriceNAV, PricePUR = s.PricePUR, InterestRate = s.InterestRate, ValuationTypeId = s.ValuationTypeId, Valuer = s.Valuer, Attachment = s.Attachment, IsDeleted = s.IsDeleted, }).ToList()); }
internal List <SecurityPriceModel> GetAllByIds(SecurityPriceModel model) { List <int> securityIds = model.TableParam.sIdsSearch; List <SecurityPriceModel> result = new List <SecurityPriceModel>(); result = _securitypriceRepository.Where(w => w.IsDeleted == false && w.Security.IsDeleted == false && securityIds.Contains(w.SecurityId) && w.Date >= (model.FromDate ?? new DateTime()) && w.Date <= (model.ToDate ?? DateTime.Now)) .Select(s => new SecurityPriceModel { Id = s.Id, SecurityId = s.SecurityId, Date = s.Date, UnitPrice = s.UnitPrice, }).OrderBy(i => i.SecurityId).ThenBy(i => i.Date).ToList(); return(result); }
private List <SecurityPriceModel> GetPaginatedData(SecurityPriceModel model, out int totalRecords) { List <SecurityPriceModel> query; var result = GetModelListByModelFieldsDateRange(model); if (string.IsNullOrWhiteSpace(model.TableParam.sSearch)) { query = result.Select(p => new SecurityPriceModel { Id = p.Id, SecurityCode = p.SecurityCode, SecurityName = p.SecurityName, Date = System.Convert.ToDateTime(p.Date), UnitPrice = p.UnitPrice, Currency = p.Currency, InterestRate = p.InterestRate }).ToList(); } else { query = result.Select(p => new SecurityPriceModel { Id = p.Id, SecurityCode = p.SecurityCode, SecurityName = p.SecurityName, Date = System.Convert.ToDateTime(p.Date), UnitPrice = p.UnitPrice, Currency = p.Currency, InterestRate = p.InterestRate }).Where(s => s.SecurityCode != null && s.SecurityCode.ToLower().Contains(model.TableParam.sSearch.ToLower()) || s.SecurityName != null && s.SecurityName.ToLower().Contains(model.TableParam.sSearch.ToLower()) || s.Date != null && string.Format("{0:dd/MM/yyyy}", s.Date).Contains(model.TableParam.sSearch) || s.UnitPrice.ToString(CultureInfo.InvariantCulture).Contains(model.TableParam.sSearch) || s.Currency != null && s.Currency.ToLower().Contains(model.TableParam.sSearch.ToLower()) || s.InterestRate != null && s.InterestRate.Value.ToString(CultureInfo.InvariantCulture).Contains(model.TableParam.sSearch.ToLower())).ToList(); } List <SecurityPriceModel> filtered = CustomFilter(model, query); totalRecords = filtered.Count; return(model.IsDownload ? filtered : SortingTableData(model, filtered)); }
protected List <SecurityPriceModel> GetAllBySecuirtyId(SecurityPriceModel model) { List <SecurityPriceModel> result = new List <SecurityPriceModel>(); result = _securitypriceRepository.Where(w => w.IsDeleted == false && w.Security.IsDeleted == false && w.SecurityId == model.SecurityId) .Select(s => new SecurityPriceModel { Id = s.Id, SecurityId = s.SecurityId, Date = s.Date, UnitPrice = s.UnitPrice, Currency = s.Currency.CurrencyName, Valuer = s.Valuer, ValuationType = s.ValuationType.Type, FileName = s.Security.UnitisedId == 1 ? s.NAVSecurityAttachments.FirstOrDefault().Attachment.FileName : string.Empty }).OrderBy(i => i.SecurityId).ToList(); return(result); }
private static List <SecurityPriceModel> CustomFilter(SecurityPriceModel model, List <SecurityPriceModel> query) { List <SecurityPriceModel> filtered = query; if (!string.IsNullOrEmpty(model.TableParam.sSearch_0)) { filtered = filtered.Where(s => s.SecurityCode != null && s.SecurityCode.ToLower().Contains(model.TableParam.sSearch_0.ToLower())).ToList(); } if (!string.IsNullOrEmpty(model.TableParam.sSearch_1)) { filtered = filtered.Where(s => s.SecurityName != null && s.SecurityName.ToLower().Contains(model.TableParam.sSearch_1.ToLower())).ToList(); } if (!string.IsNullOrEmpty(model.TableParam.sSearch_2)) { filtered = filtered.Where(s => s.Date != null && string.Format("{0:dd/MM/yyyy}", s.Date).Contains(model.TableParam.sSearch_2)).ToList(); } if (model.IsRateIndex) { if (!string.IsNullOrEmpty(model.TableParam.sSearch_3)) { filtered = filtered.Where(s => s.InterestRate.ToString().Contains(model.TableParam.sSearch_3)).ToList(); } } else { if (!string.IsNullOrEmpty(model.TableParam.sSearch_3)) { filtered = filtered.Where(s => s.UnitPrice.ToString(CultureInfo.InvariantCulture).Contains(model.TableParam.sSearch_3)).ToList(); } if (!string.IsNullOrEmpty(model.TableParam.sSearch_4)) { filtered = filtered.Where(s => s.Currency != null && s.Currency.ToLower().Contains(model.TableParam.sSearch_4.ToLower())).ToList(); } } return(filtered); }
protected List <SecurityPriceModel> GetModelListByModelFields(SecurityPriceModel modelWithValue) { return(_securitypriceRepository.GetAll(w => w.IsDeleted == false && w.Security.IsDeleted == false).Where(Createfilter <SecurityPrice>(modelWithValue)) .Select(s => new SecurityPriceModel { Id = s.Id, SecurityId = s.SecurityId, SecurityCode = s.Security.Code, SecurityName = s.Security.Name, Date = s.Date, CurrencyId = s.CurrencyId, Currency = s.Currency.Code ?? s.Security.Currency.Code, UnitPrice = s.UnitPrice, PriceNAV = s.PriceNAV, PricePUR = s.PricePUR, InterestRate = s.InterestRate, ValuationTypeId = s.ValuationTypeId, Valuer = s.Valuer, Attachment = s.Attachment, IsDeleted = s.IsDeleted, }).ToList()); }
protected List <SecurityPriceModel> GetAllLastMonthPrices(SecurityPriceModel template) { List <int> securityIds = template.TableParam.sIdsSearch; var rezult = new List <SecurityPriceModel>(); var defaultDate = new DateTime(); var allprices = _securitypriceRepository.GetAll(w => w.IsDeleted == false && w.Security.IsDeleted == false && securityIds.Contains(w.SecurityId) && w.Date >= (template.FromDate ?? defaultDate) && w.Date <= (template.ToDate ?? DateTime.Now)).Select(s => new SecurityPriceModel { Id = s.Id, SecurityId = s.SecurityId, Date = s.Date, UnitPrice = s.UnitPrice, }).OrderBy(i => i.SecurityId).ThenBy(i => i.Date).ToList(); List <SecurityPriceModel> allprices2 = _securitypriceRepository.Where(w => w.IsDeleted == false && w.Security.IsDeleted == false && securityIds.Contains(w.SecurityId) && w.Date >= (template.FromDate ?? defaultDate) && w.Date <= (template.ToDate ?? DateTime.Now)).Select(s => new SecurityPriceModel { Id = s.Id, SecurityId = s.SecurityId, Date = s.Date, UnitPrice = s.UnitPrice, }).OrderBy(i => i.SecurityId).ThenBy(i => i.Date).ToList(); var allprices22 = _securitypriceRepository.Where(w => w.IsDeleted == false && w.Security.IsDeleted == false && securityIds.Contains(w.SecurityId) && w.Date >= (template.FromDate ?? defaultDate) && w.Date <= (template.ToDate ?? DateTime.Now)).Select(s => new SecurityPriceModel { Id = s.Id, SecurityId = s.SecurityId, Date = s.Date, UnitPrice = s.UnitPrice, }).OrderBy(i => i.SecurityId).ThenBy(i => i.Date).ToList(); foreach (var id in securityIds) { var sec = allprices22.Where(w => w.SecurityId == id).ToList(); var allPricesById = allprices.Where(i => i.SecurityId == id).ToList(); if (!allPricesById.Any()) { continue; } //DateTime DateTime curtime = allPricesById.Where(i => i.Date != null).Select(i => i.Date.Value).FirstOrDefault(); while (curtime != defaultDate && curtime < new DateTime(DateTime.Now.AddMonths(-1).Year, DateTime.Now.AddMonths(-1).Month, DateTime.DaysInMonth(DateTime.Now.AddMonths(-1).Year, DateTime.Now.AddMonths(-1).Month))) { var lastprice = allPricesById.Where(i => i.Date != null && i.Date.Value.Month == curtime.Month && i.Date.Value.Year == curtime.Year).OrderBy(i => i.Date).LastOrDefault(); if (lastprice != null) { rezult.Add(lastprice); } curtime = curtime.AddMonths(1); } } return(rezult); }
private static List <SecurityPriceModel> SortingTableData(SecurityPriceModel model, List <SecurityPriceModel> filtered) { if (model.TableParam.iSortingCols == 1) { if (model.TableParam.iSortCol_0 == 0 && model.TableParam.sSortDir_0 == "asc") { return(filtered.OrderBy(od => od.SecurityCode).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); } if (model.TableParam.iSortCol_0 == 0 && model.TableParam.sSortDir_0 == "desc") { return(filtered.OrderByDescending(od => od.SecurityCode).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); } if (model.TableParam.iSortCol_0 == 1 && model.TableParam.sSortDir_0 == "asc") { return(filtered.OrderBy(p => p.SecurityName).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); } if (model.TableParam.iSortCol_0 == 1 && model.TableParam.sSortDir_0 == "desc") { return(filtered.OrderByDescending(p => p.SecurityName).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); } if (model.TableParam.iSortCol_0 == 2 && model.TableParam.sSortDir_0 == "asc") { return(filtered.OrderBy(p => p.Date).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); } if (model.TableParam.iSortCol_0 == 2 && model.TableParam.sSortDir_0 == "desc") { return(filtered.OrderByDescending(p => p.Date).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); } if (model.IsRateIndex) { if (model.TableParam.iSortCol_0 == 3 && model.TableParam.sSortDir_0 == "asc") { return(filtered.OrderBy(p => p.InterestRate).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); } if (model.TableParam.iSortCol_0 == 3 && model.TableParam.sSortDir_0 == "desc") { return(filtered.OrderByDescending(p => p.InterestRate).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); } } else { if (model.TableParam.iSortCol_0 == 3 && model.TableParam.sSortDir_0 == "asc") { return(filtered.OrderBy(p => p.UnitPrice).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); } if (model.TableParam.iSortCol_0 == 3 && model.TableParam.sSortDir_0 == "desc") { return(filtered.OrderByDescending(p => p.UnitPrice).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); } if (model.TableParam.iSortCol_0 == 4 && model.TableParam.sSortDir_0 == "asc") { return(filtered.OrderBy(p => p.Currency).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); } if (model.TableParam.iSortCol_0 == 4 && model.TableParam.sSortDir_0 == "desc") { return(filtered.OrderByDescending(p => p.Currency).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); } } return(filtered.OrderBy(x => x.SecurityCode).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); } return(filtered.OrderBy(od => od.SecurityCode).Skip(model.TableParam.iDisplayStart).Take(model.TableParam.iDisplayLength).ToList()); }