public async Task CreateAsyncShouldSetAmount(decimal amount) { var price = new Price { Amount = amount }; PriceViewModel result = await this.priceViewModelFactory.CreateAsync(price); Assert.That(result.Amount, Is.EqualTo(amount.ToString("0.##").PadLeft(6))); }
public async Task <ActionResult> Price(string selectedDish) { var dish = await _dishRepository.GetAsync(selectedDish); var viewModel = new PriceViewModel() { Price = dish.Price }; return(PartialView("_DisplayPrice", viewModel)); }
public ActionResult Save(PriceViewModel model) { var price = model.ToPrice(); price.Id = model.Id; BusinessManager.Instance.Prices.Update(price); var prices = GetParkingFromCurrentLocalAdmin().Prices; return(View("Manage", prices)); }
public async Task CreateAsyncShouldSetImageOnPriceViewModel() { IBitmap expected = new TestBitmap(); var price = new Price(); this.imageServiceMock.Setup(x => x.GetImageAsync(It.IsAny <Uri>(), It.IsAny <CancellationToken>())) .ReturnsAsync(expected); PriceViewModel result = await this.priceViewModelFactory.CreateAsync(price); Assert.That(result.Image, Is.EqualTo(expected)); }
public async Task CreateAsyncShouldSetCurrencyOnPriceViewModel() { const string expected = "Orb of Alchemy"; var price = new Price(); this.staticDataServiceMock.Setup(x => x.GetText(It.IsAny <string>())) .Returns(expected); PriceViewModel result = await this.priceViewModelFactory.CreateAsync(price); Assert.That(result.Currency, Is.EqualTo(expected)); }
public IActionResult AddPrice(Price price) { _price.Add(price); var model = new PriceViewModel { Packages = _package.GetAll().ToList(), Terms = _term.GetAll().OrderBy(term => term.Value).ToList(), }; return(RedirectToAction("Index")); }
public ActionResult Edit(PriceViewModel model) { try { // TODO: Add update logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public void Export_prices() { var model = new PriceViewModel(); CheckExport(model); using (var file = File.OpenRead(result.Filename)) { var book = new HSSFWorkbook(file); var sheet = book.GetSheetAt(0); //флаг в Работе var cell = sheet.GetRow(1).GetCell(3); Assert.AreEqual("Да", cell.StringCellValue); } }
//GET: Create public ActionResult Create() { using (GoodSupplyEntities db = new GoodSupplyEntities()) { var suppliers = db.Suppliers.ToList(); var manufacturerProducts = db.ManufacturerProducts.ToList(); var model = new PriceViewModel { Suppliers = suppliers, ManufacturerProducts = manufacturerProducts }; return(View(model)); } }
public async Task CreateShouldSetPriceViewModel(Item item) { var expected = new PriceViewModel { Amount = "2", Currency = "Chaos Orb" }; ListingResult listingResult = GetListingResult(); this.priceViewModelFactoryMock.Setup(x => x.CreateAsync(It.IsAny <Price>(), It.IsAny <CancellationToken>())) .ReturnsAsync(expected); SimpleListingViewModel result = await this.listingViewModelFactory.CreateAsync(listingResult, item); Assert.That(result.Price, Is.EqualTo(expected)); }
public ViewResult PriceCreate() { IEnumerable <RS_PRODUCT> products = repository.Productts; IEnumerable <CT_VAT> vats = repository.Vats; var priceVM = new PriceViewModel { Price = new RS_PRICE(), Products = products, Vats = vats }; return(View("PriceEdit", priceVM)); }
public ActionResult PriceEdit(PriceViewModel priceVM) { if (ModelState.IsValid) { repository.SavePrice(priceVM.Price); TempData["message"] = string.Format("{0} сохранено", priceVM.Price.PriceId.ToString()); return(RedirectToAction("Prices")); } else { // что-то не так с значениями данных (there is something wrong with the data values) return(View(priceVM)); } }
public HttpResponseMessage Create(HttpRequestMessage request, PriceViewModel priceCategoryVm) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { var newprice = new Price(); newprice.UpdatePrice(priceCategoryVm); var PriceExists = _priceService.GetPrice(newprice.ProductID, newprice.SizeID, newprice.ColorID); if (PriceExists != null && PriceExists.ID > 0) { response = request.CreateResponse(HttpStatusCode.BadGateway, new { ErrorMesage = "Sản phẩm đã được làm giá." }); } else { _priceService.Add(newprice); if (newprice.IsPrimary) { var pricePrimary = new Price(); pricePrimary = _priceService.GetByPrimary(newprice.ProductID); if (pricePrimary != null && pricePrimary.ProductID > 0) { pricePrimary.IsPrimary = false; _priceService.Update(pricePrimary); } } else { var priceProduct = _priceService.GetPriceProduct(newprice.ProductID); if (priceProduct == null || priceProduct.Count() == 0) { newprice.IsPrimary = true; } } _priceService.SaveChanges(); var responseData = Mapper.Map <Price, PriceViewModel>(newprice); response = request.CreateResponse(HttpStatusCode.Created, responseData); } } return response; })); }
public ViewResult PriceEdit(long priceId) { RS_PRICE price = repository.Prices.Where(x => x.PriceId == priceId).FirstOrDefault(); IEnumerable <RS_PRODUCT> products = repository.Productts; IEnumerable <CT_VAT> vats = repository.Vats; var priceVM = new PriceViewModel { Price = price, Products = products, Vats = vats }; return(View(priceVM)); }
public ActionResult Create(int?id) { var userName = System.Web.HttpContext.Current.User.Identity.Name; var user = _systemService.GetUserAndRole(0, userName); if (user == null) { return(RedirectToAction("Index", "Login")); } if (user.PriceR == 0) { return(RedirectToAction("Index", "Home")); } var item = new V3_Price_By_Id(); if (id.HasValue) { item = _service.GetByKeySp(id.Value, "1"); } var model = new PriceViewModel { Id = item.Id, StockId = item.Stock_Id, StockCode = item.Stock_Code, StockName = item.Stock_Name, Price = item.Price, CurrencyId = item.Currency_Id, SupplierId = item.Supplier_Id, StoreId = item.Store_Id, dStart = item.Start, dEnd = item.End, StockType = item.Stock_Type, Unit = item.Unit, PartNo = item.Part_No, RalNo = item.Ral_No, ColorName = item.Color, Timestamp = item.Timestamp, UserLogin = user, Stores = new SelectList(_systemService.StoreList(), "Id", "Name"), Suppliers = new SelectList(_systemService.SupplierList(), "bSupplierID", "vSupplierName"), Currencies = new SelectList(_systemService.CurrencyList(), "Id", "Name") }; return(View(model)); }
public void SetTotalPriceWithAlbum_150and240_390() { //// Set Currency var userCurrency = new CurrencyViewModel(); userCurrency.Code = 840; userCurrency.ShortName = "USD"; //// Set TrackPrices var priceTrack = new PriceViewModel(); priceTrack.Currency = userCurrency; priceTrack.Amount = 120; //// Create two tracks with total price = 240 var track1 = new TrackDetailsViewModel() { Name = "SuperTrack1", Price = priceTrack }; var track2 = new TrackDetailsViewModel() { Name = "SuperTrack2", Price = priceTrack }; //// Set TrackPrices var priceAlbum = new PriceViewModel(); priceAlbum.Currency = userCurrency; priceAlbum.Amount = 150; //// Create album with price = 150 var album1 = new AlbumDetailsViewModel() { Name = "MyAlbum", Price = priceAlbum }; //// Create and set CartView model var myCartView = new CartViewModel() { Tracks = new List <TrackDetailsViewModel>(), Albums = new List <AlbumDetailsViewModel>() }; myCartView.Tracks.Add(track1); myCartView.Tracks.Add(track2); myCartView.Albums.Add(album1); CartViewModelService.SetTotalPrice(myCartView, userCurrency); Assert.IsTrue(myCartView.TotalPrice == 390); }
public ActionResult Create(PriceViewModel model) { var geocoder = new Geocoder(); if (!api.ProductIsValid(model.selectedProduct)) { ModelState.AddModelError("selectedProduct", "El producto no es valido"); return(View("Create", model)); } var latlong = geocoder.GetLatLong(model.location); if (latlong == null) { ModelState.AddModelError("location", "La direccion no es valida"); return(View("Create", model)); } if (!new CityService().IsInBsAs(new PointF((float)latlong.Item1, (float)latlong.Item2))) { model.location = String.Empty; ModelState.AddModelError("location", "La direccion es invalida"); return(View("Create", model)); } var product = api.GetProductByName(model.selectedProduct); if (product.Name == null) { model.selectedProduct = String.Empty; ModelState.AddModelError("selectedProduct", "El producto no existe"); return(View("Create", model)); } var price = new Price() { price = model.price, Id = Guid.Empty, latitude = latlong.Item1, longitude = latlong.Item2, product = product, date = DateTimeOffset.Now }; if (api.SavePrice(price)) { return(RedirectToAction("Index", "")); } return(View("Error")); }
public FormationDocumentPrice(PriceViewModel model) { this.Mod = model; PriceDocContext context = new PriceDocContext(); this.Aut = context.AuthoryPrice.Find(Convert.ToInt32(model.IndexOgv)); if (model.QrCodeForEachPart != null) { FlagQrCode = true; } ListPurpose = new List <Purpose>(); for (int i = 0; i < model.IndexPurpose.Length; i++) { ListPurpose.Add(context.Purposes.Find(Convert.ToInt32(model.IndexPurpose[i]))); } }
// GET: Prices/Create public async Task <IActionResult> Create() { var changes = new SelectList(await _uow.Changes.AllAsync(), "Id", "ChangeName") .Prepend(new SelectListItem { Text = "Select change", Value = "" }); var products = new SelectList(await _uow.Products.AllAsync(), "Id", "ProductName") .Prepend(new SelectListItem { Text = "Select product", Value = "" }); var viewModel = new PriceViewModel { ChangeSelectList = changes, ProductSelectList = products }; return(View(viewModel)); }
public IActionResult EditPrice(int Id) { var price = _price.FindById(Id); if (price == null) { return(RedirectToAction("Error404", "Error")); } var model = new PriceViewModel { Packages = _package.GetAll().ToList(), Terms = _term.GetAll().OrderBy(term => term.Value).ToList(), Price = price }; return(View(model)); }
public async Task <IActionResult> Update(Guid priceId, [FromBody] PriceViewModel priceVM) { try { var userId = Guid.Parse(_httpContextAccessor.HttpContext.User.FindFirstValue("NameId")); var priceDto = _mapper.Map <PriceViewModel, PriceDto>(priceVM); priceDto.LastModificationBy = userId; await _priceUseCases.Update(priceId, priceDto); return(Ok("Price successfully updated.")); } catch (KeyNotFoundException) { return(NotFound()); } }
public ActionResult LoadPrice(int page, int size, int store, int supplier, string stockCode, string stockName, int status, string fd, string td, string enable) { var userName = System.Web.HttpContext.Current.User.Identity.Name; var totalRecord = _service.ListConditionCount(page, size, store, supplier, stockCode, stockName, status, fd, td, enable); var totalTemp = Convert.ToDecimal(totalRecord) / Convert.ToDecimal(size); var totalPages = Convert.ToInt32(Math.Ceiling(totalTemp)); var model = new PriceViewModel { UserLogin = _systemService.GetUserAndRole(0, userName), ListPrice = _service.ListCondition(page, size, store, supplier, stockCode, stockName, status, fd, td, enable), TotalRecords = Convert.ToInt32(totalRecord), TotalPages = totalPages, CurrentPage = page, PageSize = size }; return(PartialView("_PricePartial", model)); }
public async Task <IHttpActionResult> ReadPurchasePrices([FromUri] PaginationQuery paginationQuery) { try { IEnumerable <Price> prices = await Task.FromResult(priceRepository.GetAll( PriceTypeEnum.Purchase, paginationQuery.Skip, paginationQuery.Limit)); return(new HttpJsonApiResult <IEnumerable <PriceViewModel> >( PriceViewModel.GetAll(prices), Request, HttpStatusCode.OK)); } catch (Exception) { return(new HttpJsonApiResult <string>("Internal Server Error", Request, HttpStatusCode.InternalServerError)); } }
public ActionResult Add(PriceViewModel model) { var parking = GetParkingFromCurrentLocalAdmin(); var price = model.ToPrice(); price.Parking = parking; try { BusinessManager.Instance.Prices.Add(price); } catch (UniqueKeyViolationException) { ModelState.AddModelError("", "Já existe um preço nesse intervalo de horário"); return(View(model)); } var prices = GetParkingFromCurrentLocalAdmin().Prices; return(View("Manage", prices)); }
/// <summary> /// 区域用能费用报表 /// 初始加载:获取用户名查询建筑列表,第一栋建筑对应的分类,第一个分类对应的所有区域的用能天报表 /// </summary> /// <param name="userName">用户名</param> /// <returns>返回完整的数据:包含建筑列表,能源按钮列表,区域列表,以及用能数据天报表,分类能耗单价</returns> public PriceViewModel GetViewModelByUserName(string userName) { PriceViewModel viewModel = new PriceViewModel(); List <BuildViewModel> builds = context.GetBuildsByUserName(userName); string buildId; if (builds.Count > 0) { buildId = builds.First().BuildID; } else { buildId = ""; } viewModel.EnergyPrice = GetEnergyPrice(buildId); viewModel.RegionReportModel = service.GetViewModelByUserName(userName); return(viewModel); }
private JsonResult EditData(PriceViewModel model) { var entity = _service.GetByKey(model.ProductPrice.Id); if (!Convert.ToBase64String(model.ProductPrice.Timestamp).Equals(Convert.ToBase64String(entity.Timestamp))) { return(Json(new { result = Constants.DataJustChanged })); } try { if (!string.IsNullOrEmpty(model.dStartTemp)) { entity.dStart = DateTime.ParseExact(model.dStartTemp, "MM/dd/yyyy", new CultureInfo(Constants.MyCultureInfo)); } if (!string.IsNullOrEmpty(model.dEndTemp)) { entity.dEnd = DateTime.ParseExact(model.dEndTemp, "MM/dd/yyyy", new CultureInfo(Constants.MyCultureInfo)); } entity.Price = model.ProductPrice.Price; entity.CurrencyId = model.ProductPrice.CurrencyId; entity.SupplierId = model.ProductPrice.SupplierId; entity.StoreId = model.ProductPrice.StoreId; entity.iModified = model.LoginId; entity.dModified = DateTime.Now; entity.Status = SetStatus(entity.dStart, entity.dEnd); this._service.Update(entity); return(Json(new { result = Constants.Success })); } catch (Exception e) { Log.Error("Update Price!", e); return(Json(new { result = Constants.UnSuccess })); } }
public ActionResult AssignPrice(int id, PriceViewModel priceViewModel) { using (var context = new ApplicationDbContext()) { var startDate = PersianDateTime.Parse(ConvertToEn(priceViewModel.FaStartDate)).ToDateTime(); var endDate = PersianDateTime.Parse(ConvertToEn(priceViewModel.FaStartDate)).ToDateTime(); if (startDate > endDate) { throw new Exception("تاریخ شروع باید از تاریخ پایان کمتر باشد."); } var price = new Price() { Amount = priceViewModel.Amount, EndDate = endDate, StartDate = startDate, MeatPartId = id }; context.Prices.Add(price); context.SaveChanges(); return(RedirectToAction("Index", context.MeatParts.ToList())); } }
// GET: Farmer/Pricing/Create public ActionResult AddCropPrice(int?farmCropId) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <CropPrice, PriceViewModel>(); }); PriceViewModel model = null; IMapper iMapper = config.CreateMapper(); //if (Id.HasValue && Id.Value > 0) //{ // CropPrice updateCropPrice = CropPriceService.GetById(Id.Value); // model = iMapper.Map<CropPrice, PriceViewModel>(updateCropPrice); // model.MeasurementDropDown = base.GetMeasurement(updateCropPrice.Id); // return PartialView(model); //} model = iMapper.Map <CropPrice, PriceViewModel>(new CropPrice()); model.FarmCropId = farmCropId.Value; model.MeasurementDropDown = base.GetMeasurement(null); return(PartialView("_AddCropPricing", model)); }
public JsonResult TotalScoreResult(string id, decimal price) { var generalparcel = db.GeneralInfoParcels.ToList(); var totalscoreresult = new List <PriceViewModel>(); foreach (var general in generalparcel) { var pricedetail = new PriceViewModel(); var askedPrice = db.PriceSetting.Where(x => x.generalparcelID == general.Id).FirstOrDefault(); pricedetail.ParacelNo = general.ParcelNo; pricedetail.Name = general.OwnerName; pricedetail.MapSheetNo = general.MapsheetNo; pricedetail.NetScore = Math.Round(GetTotalScore(general.Id), 4); pricedetail.BaseId = id; pricedetail.PerUnitPrice = Math.Round(askedPrice.AskedPrice / pricedetail.NetScore, 4); pricedetail.PerUnitSquareMeterPrice = Math.Round(price / general.sqmeter, 4); pricedetail.PerSquaremeterPrice = Math.Round(GetTotalScore(general.Id) * pricedetail.PerUnitSquareMeterPrice, 4); pricedetail.TotalPrice = Math.Round(general.TotalArea * pricedetail.PerSquaremeterPrice, 4); totalscoreresult.Add(pricedetail); } return(Json(totalscoreresult, JsonRequestBehavior.AllowGet)); }
public ActionResult Index() { var userName = System.Web.HttpContext.Current.User.Identity.Name; var user = _systemService.GetUserAndRole(0, userName); if (user == null) { return(RedirectToAction("Index", "Login")); } if (user.RequisitionR == 0) { return(RedirectToAction("Index", "Home")); } var model = new PriceViewModel { UserLogin = user, Stores = new SelectList(_systemService.StoreList(), "Id", "Name"), Suppliers = new SelectList(_systemService.SupplierList(), "Id", "Name"), StatusPrice = new SelectList(this._systemService.GetLookUp(Constants.LuPriceStatus), Constants.LookUpKey, Constants.LookUpValue), }; return(View(model)); }
public JsonResult Create(PriceViewModel model) { if (model.V3 != true) { return Json(new { result = Constants.UnSuccess }); } return model.Id == 0 ? CreateData(model) : EditData(model); }
private JsonResult CreateData(PriceViewModel model) { try { if (!string.IsNullOrEmpty(model.dStartTemp)) { model.ProductPrice.dStart = DateTime.ParseExact(model.dStartTemp, "MM/dd/yyyy", new CultureInfo(Constants.MyCultureInfo)); } if (!string.IsNullOrEmpty(model.dEndTemp)) { model.ProductPrice.dEnd = DateTime.ParseExact(model.dEndTemp, "MM/dd/yyyy", new CultureInfo(Constants.MyCultureInfo)); } model.ProductPrice.iEnable = true; model.ProductPrice.iCreated = model.LoginId; model.ProductPrice.dCreated = DateTime.Now; model.ProductPrice.Status = SetStatus(model.ProductPrice.dStart, model.ProductPrice.dEnd); _service.Insert(model.ProductPrice); return Json(new { result = Constants.Success }); } catch (Exception e) { Log.Error("Create New Price!", e); return Json(new { result = Constants.UnSuccess }); } }
public ActionResult LoadPrice(int page, int size, int store, int supplier, string stockCode, string stockName, int status, string fd, string td, string enable) { var userName = System.Web.HttpContext.Current.User.Identity.Name; var totalRecord = _service.ListConditionCount(page, size, store, supplier, stockCode, stockName, status, fd, td, enable); var totalTemp = Convert.ToDecimal(totalRecord) / Convert.ToDecimal(size); var totalPages = Convert.ToInt32(Math.Ceiling(totalTemp)); var model = new PriceViewModel { UserLogin = _systemService.GetUserAndRole(0, userName), ListPrice = _service.ListCondition(page, size, store, supplier, stockCode, stockName, status, fd, td, enable), TotalRecords = Convert.ToInt32(totalRecord), TotalPages = totalPages, CurrentPage = page, PageSize = size }; return PartialView("_PricePartial", model); }
public ActionResult Create(int? id) { var userName = System.Web.HttpContext.Current.User.Identity.Name; var user = _systemService.GetUserAndRole(0, userName); if (user == null) { return RedirectToAction("Index", "Login"); } if (user.PriceR == 0) { return RedirectToAction("Index", "Home"); } var item = new V3_Price_By_Id(); if (id.HasValue) { item = _service.GetByKeySp(id.Value, "1"); } var model = new PriceViewModel { Id = item.Id, StockId = item.Stock_Id, StockCode = item.Stock_Code, StockName = item.Stock_Name, Price = item.Price, CurrencyId = item.Currency_Id, SupplierId = item.Supplier_Id, StoreId = item.Store_Id, dStart = item.Start, dEnd = item.End, StockType = item.Stock_Type, Unit = item.Unit, PartNo = item.Part_No, RalNo = item.Ral_No, ColorName = item.Color, Timestamp = item.Timestamp, UserLogin = user, Stores = new SelectList(_systemService.StoreList(), "Id", "Name"), Suppliers = new SelectList(_systemService.SupplierList(), "bSupplierID", "vSupplierName"), Currencies = new SelectList(_systemService.CurrencyList(), "Id", "Name") }; return View(model); }
public ActionResult Index() { var userName = System.Web.HttpContext.Current.User.Identity.Name; var user = _systemService.GetUserAndRole(0, userName); if (user == null) return RedirectToAction("Index", "Login"); if (user.RequisitionR == 0) return RedirectToAction("Index", "Home"); var model = new PriceViewModel { UserLogin = user, Stores = new SelectList(_systemService.StoreList(), "Id", "Name"), Suppliers = new SelectList(_systemService.SupplierList(), "Id", "Name"), StatusPrice = new SelectList(this._systemService.GetLookUp(Constants.LuPriceStatus), Constants.LookUpKey, Constants.LookUpValue), }; return View(model); }
private JsonResult EditData(PriceViewModel model) { var entity = _service.GetByKey(model.ProductPrice.Id); if (!Convert.ToBase64String(model.ProductPrice.Timestamp).Equals(Convert.ToBase64String(entity.Timestamp))) { return Json(new { result = Constants.DataJustChanged }); } try { if (!string.IsNullOrEmpty(model.dStartTemp)) { entity.dStart = DateTime.ParseExact(model.dStartTemp, "MM/dd/yyyy", new CultureInfo(Constants.MyCultureInfo)); } if (!string.IsNullOrEmpty(model.dEndTemp)) { entity.dEnd = DateTime.ParseExact(model.dEndTemp, "MM/dd/yyyy", new CultureInfo(Constants.MyCultureInfo)); } entity.Price = model.ProductPrice.Price; entity.CurrencyId = model.ProductPrice.CurrencyId; entity.SupplierId = model.ProductPrice.SupplierId; entity.StoreId = model.ProductPrice.StoreId; entity.iModified = model.LoginId; entity.dModified = DateTime.Now; entity.Status = SetStatus(entity.dStart, entity.dEnd); this._service.Update(entity); return Json(new { result = Constants.Success }); } catch (Exception e) { Log.Error("Update Price!", e); return Json(new { result = Constants.UnSuccess }); } }