public async Task <ActionResult> Create(PricesViewModel model) { var path = string.Format("{0}{1}", HttpClientProvider.HttpClient.BaseAddress, Base_Address); //model.PricesId = Guid.NewGuid().ToString(); try { // TODO: Add insert logic here if (ModelState.IsValid) { var altPath = string.Format("{0}/{1}/{2}", AlternatePost_Address, model.Type, model.Price); //var result = await _apiClient.PostAsync(path, //_mapper.Map<PricesDto>(model)); var result = await _apiClient.GetAsync <PricesDto>(altPath); return(RedirectToAction(nameof(Index))); } return(View()); } catch (Exception ex) { var errMsg = ex.Message; return(View()); } }
public async Task <ActionResult> Edit(PricesViewModel model) { var path = string.Format("{0}/{1}", Base_Address, GuidEncoder.Decode(model.UriKey)); try { // TODO: Add insert logic here if (ModelState.IsValid) { var pathUpdate = string.Format("{0}/{1}/{2}", AlternatePut_Address, GuidEncoder.Decode(model.UriKey), model.Price); //model.PricesId = GuidEncoder.Decode(model.UriKey).ToString(); //await _apiClient.PutAsync(path, // _mapper.Map<PricesDto>(model)); await _apiClient.GetAsync <PricesDto>(pathUpdate); return(RedirectToAction(nameof(Index))); } return(View("CreateEdit", model)); } catch (Exception ex) { var errMsg = ex.Message; return(View("CreateEdit", model)); } }
public PartialViewResult BaseJournalPrices(PricesViewModel model) { this.ViewBag.RefererUrl = model.RefererUrl; var journalPrices = this.baseJournalPriceRepository.Find(model.ToJournalPriceFilter(null)); return(this.PartialView(journalPrices)); }
public PartialViewResult InstitutionJournalPrices(PricesViewModel model) { this.ViewBag.RefererUrl = model.RefererUrl; var institutionJournals = this.institutionJournalRepository.Find(model.ToInstitutionJournalPriceFilter()); return(this.PartialView(institutionJournals)); }
public PartialViewResult ValuationJournalPrices(PricesViewModel model) { this.ViewBag.RefererUrl = model.RefererUrl; var journalPrices = this.valuationJournalPriceRepository.Find(model.ToJournalPriceFilter(FeeType.Article)); return(this.PartialView(journalPrices)); }
public PartialViewResult BaseJournalPrices(PricesViewModel model) { ViewBag.RefererUrl = model.RefererUrl; var journalPrices = baseJournalPriceRepository.Find(model.ToJournalPriceFilter(null)); return PartialView(journalPrices); }
public PricesPage() { InitializeComponent(); var vm = new PricesViewModel(); vm.Navigation = Navigation; BindingContext = vm; }
public PartialViewResult Prices(PricesViewModel model) { this.ViewBag.RefererUrl = model.RefererUrl; model.InstitutionJournals = this.institutionJournalRepository.Find(model.ToInstitutionJournalPriceFilter()); model.BaseJournalPrices = this.baseJournalPriceRepository.Find(model.ToJournalPriceFilter(null)); model.ValuationJournalPrices = this.valuationJournalPriceRepository.Find(model.ToJournalPriceFilter(FeeType.Article)); model.Journal = this.journalRepository.Find(model.Id); return(this.PartialView(model)); }
public ActionResult PriceDestroy([DataSourceRequest] DataSourceRequest request, PricesViewModel dictionary) { if (dictionary != null) { Price d = _db.Prices.First(o => o.Id == dictionary.Id); _db.Prices.Remove(d); _db.SaveChanges(); } return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState))); }
public ActionResult PriceUpdate([DataSourceRequest] DataSourceRequest request, PricesViewModel dictionary) { PriceProjectsView projectRkk = _db.PriceProjectsViews.FirstOrDefault(x => x.Id == dictionary.PriceProjectId); decimal count = 0; if (projectRkk != null) { decimal.TryParse(projectRkk.CountPackage, out count); if (count == 0) { count++; } } DateTime now = DateTime.Now.Date; decimal cost = dictionary.ManufacturerPrice; if (dictionary.ManufacturerPriceCurrencyDicId.HasValue) { var valutaPw = _db.Dictionaries.FirstOrDefault(x => x.Id == dictionary.ManufacturerPriceCurrencyDicId.Value); if (valutaPw != null) { var rateYear = now.Month == 1 ? now.Year - 1 : now.Year; var rateMonth = now.Month == 1 ? 12 : now.Month - 1; var valutaObk = _db.obk_currencies.FirstOrDefault(x => x.currency_code == valutaPw.Code); if (valutaObk != null) { var exch = _db.AvgExchangeRatesViews.FirstOrDefault(x => x.currency_id == valutaObk.id && x.year == rateYear && x.month == rateMonth) ?? _db.AvgExchangeRatesViews.Where(x => x.currency_id == valutaObk.id && x.year <= rateYear && x.month <= rateMonth) .OrderByDescending(x => x.year).ThenByDescending(x => x.month).FirstOrDefault(); if (exch != null) { cost = cost * exch.rate.Value; } } } } var price = _db.Prices.First(o => o.Id == dictionary.Id); price.ManufacturerPriceCurrencyDicId = dictionary.ManufacturerPriceCurrencyDicId; price.ManufacturerPrice = dictionary.ManufacturerPrice; price.RefPrice = cost; price.CipPrice = cost / count; price.CountryId = dictionary.CountryId; price.Name = dictionary.Name; price.CreatedDate = DateTime.Now; _db.SaveChanges(); var result = _db.PricesViews.First(o => o.Id == price.Id); return(Json(new[] { result }.ToDataSourceResult(request))); }
public ActionResult PriceCreate([DataSourceRequest] DataSourceRequest request, PricesViewModel dictionary, Guid id) { PriceProjectsView projectRkk = _db.PriceProjectsViews.FirstOrDefault(x => x.Id == id); decimal count = 0; if (projectRkk != null) { decimal.TryParse(projectRkk.CountPackage, out count); if (count == 0) { count++; } } DateTime now = DateTime.Now.Date; decimal cost = dictionary.ManufacturerPrice; if (dictionary.ManufacturerPriceCurrencyDicId.HasValue) { var valutaPw = _db.Dictionaries.FirstOrDefault(x => x.Id == dictionary.ManufacturerPriceCurrencyDicId.Value); if (valutaPw != null) { var rateYear = now.Month == 1 ? now.Year - 1 : now.Year; var rateMonth = now.Month == 1 ? 12 : now.Month - 1; var valutaObk = _db.obk_currencies.FirstOrDefault(x => x.currency_code == valutaPw.Code); if (valutaObk != null) { // берем курс за текущий день // если нет то последний актуальный из существующих var exch = _db.AvgExchangeRatesViews.FirstOrDefault(x => x.currency_id == valutaObk.id && x.year == rateYear && x.month == rateMonth) ?? _db.AvgExchangeRatesViews.Where(x => x.currency_id == valutaObk.id && x.year <= rateYear && x.month <= rateMonth) .OrderByDescending(x => x.year).ThenByDescending(x => x.month).FirstOrDefault(); if (exch != null) { cost = cost * exch.rate.Value; } } } } Price price = new Price() { Id = Guid.NewGuid(), PriceProjectId = id, ManufacturerPriceCurrencyDicId = dictionary.ManufacturerPriceCurrencyDicId, ManufacturerPrice = dictionary.ManufacturerPrice, RefPrice = cost, CipPrice = cost / count, CountryId = dictionary.CountryId, Name = dictionary.Name, CreatedDate = DateTime.Now, Type = 99 }; _db.Prices.Add(price); _db.SaveChanges(); var result = _db.PricesViews.First(o => o.Id == price.Id); return(Json(new[] { result }.ToDataSourceResult(request))); }
protected override XamDataGrid DataGrid => null; //this.BlocksGroupBox.Content as XamDataGrid; public PricesView(PricesViewModel viewModel, IRegionManager regionManager, IEventAggregator eventAggregator, IMessageService messageService) : base(viewModel, regionManager, eventAggregator, messageService) { InitializeComponent(); this.DataContext = viewModel; }
public PartialViewResult ValuationJournalPrices(PricesViewModel model) { ViewBag.RefererUrl = model.RefererUrl; var journalPrices = valuationJournalPriceRepository.Find(model.ToJournalPriceFilter(FeeType.Article)); return PartialView(journalPrices); }
public PartialViewResult Prices(PricesViewModel model) { ViewBag.RefererUrl = model.RefererUrl; model.InstitutionJournals = institutionJournalRepository.FindAll(model.ToInstitutionJournalPriceFilter()); model.BaseJournalPrices = baseJournalPriceRepository.Find(model.ToJournalPriceFilter(null)); model.ValuationJournalPrices = valuationJournalPriceRepository.Find(model.ToJournalPriceFilter(FeeType.Article)); model.Journal = journalRepository.Find(model.Id); return PartialView(model); }
public PartialViewResult InstitutionJournalPrices(PricesViewModel model) { ViewBag.RefererUrl = model.RefererUrl; var institutionJournals = institutionJournalRepository.Find(model.ToInstitutionJournalPriceFilter()); return PartialView(institutionJournals); }
public ActionResult Create() { var newPrice = new PricesViewModel(); return(View("CreateEdit", newPrice)); }