public ActionResult GetPriceType3(ModelRequest request, Guid id) { var items = db.PricesViews.Where(o => o.PriceProjectId == id && o.Type == 3); /* var count = items.Count(); * * var data = new * { * draw = request.Draw, * recordsFiltered = count, * recordsTotal = count, * Data = items.ToList() * };*/ var countyDics = new ReadOnlyDictionaryRepository().GetDictionaries(CodeConstManager.DIC_COUNTRY_TYPE); var list = countyDics.Where(e => CodeConstManager.LIST_COUNTY_CODE_FOR_PRICE.Contains(e.Code)); var prices = new ArrayList(); var ids = new List <Guid>(); foreach (var country in list) { var exist = items.FirstOrDefault(e => e.CountryId == country.Id); if (exist != null) { prices.Add(exist); ids.Add(exist.Id); } else { var price = new { Id = Guid.NewGuid(), CountryName = country.Name, ManufacturerPrice = "", ManufacturerPriceNote = "", Type = (int)PriceType.ImnPrice, PriceProjectId = id, CountryId = country.Id, }; prices.Add(price); } } foreach (var item in items.Where(e => !ids.Contains(e.Id))) { prices.Add(item); } var count = prices.Count; var data = new { draw = request.Draw, recordsFiltered = count, recordsTotal = count, Data = prices }; return(Json(data, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Для таблицы сведения о стране в ЛС /// </summary> /// <param name="request"></param> /// <param name="id"></param> /// <returns>Json</returns> public ActionResult GetPriceCountry(ModelRequest request, Guid id) { var items = db.PricesViews.Where(o => o.PriceProjectId == id && o.Type == (int)PriceType.LsPrice); var itemsVm = items.Select(i => new { Id = i.Id, PriceProjectId = i.PriceProjectId, CountryId = i.CountryId, Type = i.Type, CountryName = i.CountryName, ManufacturerPrice = i.ManufacturerPrice, ManufacturerPriceNote = i.ManufacturerPriceNote, ManufacturerPriceCurrencyDicId = i.ManufacturerPriceCurrencyDicId, ManufacturerPriceWithLink = i.ManufacturerPrice.ToString() + " " + i.ManufacturerPriceCurrencyName + " " + i.ManufacturerPriceNote, LimitPrice = i.LimitPrice, LimitPriceCurrencyDicId = i.LimitPriceCurrencyDicId, LimitPriceNote = i.LimitPriceNote, LimitPriceWithLink = i.LimitPrice.ToString() + " " + i.LimitPriceCurrencyName + " " + i.LimitPriceNote, AvgOptPrice = i.AvgOptPrice, AvgOptPriceCurrencyDicId = i.AvgOptPriceCurrencyDicId, AvgOptPriceNote = i.AvgOptPriceNote, AvgOptPriceWithLink = i.AvgOptPrice.ToString() + " " + i.AvgOptPriceCurrencyName + " " + i.AvgOptPriceNote, AvgRozPrice = i.AvgRozPrice, AvgRozPriceCurrencyDicId = i.AvgRozPriceCurrencyDicId, AvgRozPriceNote = i.AvgRozPriceNote, AvgRozPriceWithLink = i.AvgRozPrice.ToString() + " " + i.AvgRozPriceCurrencyName + " " + i.AvgOptPriceNote, IsIncluded = i.IsIncluded, i.IsAvgOptPrice, i.IsAvgRozPrice, i.IsLimitPrice, i.IsManufacturerPrice, i.IsUnitPrice }); var countyDics = new ReadOnlyDictionaryRepository().GetDictionaries(CodeConstManager.DIC_COUNTRY_TYPE); var list = countyDics.Where(e => CodeConstManager.LIST_COUNTY_CODE_FOR_PRICE.Contains(e.Code)); var prices = new ArrayList(); var ids = new List <Guid>(); foreach (var country in list) { var exist = itemsVm.FirstOrDefault(e => e.CountryId == country.Id); if (exist != null) { prices.Add(exist); ids.Add(exist.Id); } else { var price = new { Id = Guid.NewGuid(), CountryName = country.Name, Type = (int)PriceType.LsPrice, PriceProjectId = id, CountryId = country.Id, ManufacturerPriceNote = "", ManufacturerPriceWithLink = "", LimitPriceNote = "", LimitPriceWithLink = "", AvgOptPriceNote = "", AvgOptPriceWithLink = "", AvgRozPriceNote = "", AvgRozPriceWithLink = "", IsIncluded = false /* ManufacturerPrice = 0, * ManufacturerPriceNote = "", * ManufacturerPriceCurrencyDicId = Guid.Empty, * ManufacturerPriceWithLink = "", * LimitPrice = 0, * LimitPriceCurrencyDicId = Guid.Empty, * LimitPriceNote = "", * LimitPriceWithLink = "", * AvgOptPrice =0, * AvgOptPriceCurrencyDicId = Guid.Empty, * AvgOptPriceNote = "", * AvgOptPriceWithLink = "", * AvgRozPrice = 0, * AvgRozPriceCurrencyDicId = i.AvgRozPriceCurrencyDicId, * AvgRozPriceNote = i.AvgRozPriceNote, * AvgRozPriceWithLink = i.AvgRozPrice.ToString() + " " + i.AvgRozPriceCurrencyName + " " + i.AvgOptPriceNote*/ }; prices.Add(price); } } foreach (var item in itemsVm.Where(e => !ids.Contains(e.Id))) { prices.Add(item); } var count = prices.Count; var data = new { draw = request.Draw, recordsFiltered = count, recordsTotal = count, Data = prices }; return(Json(data, JsonRequestBehavior.AllowGet)); }