public SellPage() { var vm = new SellModel(); this.BindingContext = vm; InitializeComponent(); }
public void Sell_ModelStateError_Test() { //Arrange Mock <ICategoriesRepository> category = new Mock <ICategoriesRepository>(); category.Setup(m => m.Categories).Returns(new[] { new Category { CategoryId = 1, CategoryName = "Cat1", }, new Category { CategoryId = 1, CategoryName = "Cat2", }, new Category { CategoryId = 1, CategoryName = "Cat3", } }.AsQueryable()); SellerController controller = new SellerController(null, category.Object); controller.ModelState.AddModelError("test", "test"); SellModel q = new SellModel { Name = "P1", Files = new List <HttpPostedFileBase>() }; //Act ActionResult result = controller.Sell(q, "Cat3"); // Assert Assert.IsInstanceOfType(result, typeof(ViewResult)); }
public ActionResult sell() { SellModel slm = new SellModel(); ViewData["MyYiku"] = "sell"; return(View(slm)); }
/// <summary> /// Step 1. 在本期销项明细表和本期进项明细表中找到直运的记录 /// </summary> /// <param name="sellModel"></param> /// <param name="buyModelList"></param> private static void Step1_FindDirectBusiness(SellModel sellModel, List <BuyModel> buyModelList) { //在本期进项明细表中查找货号 var buyModelList_ProductNoMatched = buyModelList.Where(v => v.ProductNo.Equals(sellModel.ProductNo)).ToList(); //正好有一个货号匹配的并且产品数相同,则视为“直运” if (buyModelList_ProductNoMatched.Count == 1) { if (buyModelList_ProductNoMatched[0].ReceiveTicketCount == sellModel.ProductCount) { var buyModel = buyModelList_ProductNoMatched[0]; // 设置销项 sellModel.SetSellMode(SellModelSaleMode.DirectBusiness); sellModel.SetCaiGouContractNo(buyModel.BuyContractNo); sellModel.SetCaiGouDanWei(buyModel.XiaoFangMinCheng); sellModel.SetJinXiangShouPiaoDunShu(buyModel.ReceiveTicketCount); sellModel.RelativeBusinessIds.Add(buyModel.Id); //设置进项 buyModel.SetSellMode(BuyModelSaleMode.DirectBusiness); buyModel.RelativeBusinessIds.Add(sellModel.BusinessNo); } } }
/// <summary> /// Step 2. 在商务报表查找符合条件的"结转前期库存" /// </summary> /// <param name="sellModel"></param> /// <param name="mappingEntityList"></param> private static void Step2_ProcessJieSuanQianQiKuCun(SellModel sellModel, List <MappingModel> mappingModelList) { //在商务报表中查找货号 var mappingModelList_Buy = mappingModelList.Where(v => v.ProductNo.Equals(sellModel.ProductNo) && v.MaiMai == 2).ToList(); var mappingModelList_Sell = mappingModelList.Where(v => v.ProductNo.Equals(sellModel.ProductNo) && v.MaiMai == 1).ToList(); var buyTotalCount = mappingModelList_Buy.Sum(v => v.KaiChuShouDaoFaPiaoDunShu); var sellTotalCount = mappingModelList_Sell.Sum(v => v.KaiChuShouDaoFaPiaoDunShu); if (buyTotalCount == sellTotalCount) { List <string> butContractNoList = mappingModelList_Buy.Select(v => v.ContractNo).Distinct().ToList(); List <string> gouXiaoHeTongTaiTou = mappingModelList_Buy.Select(v => v.GouXiaoHeTongTaiTou).Distinct().ToList(); //设置销项 sellModel.SetSellMode(SellModelSaleMode.JieSuanQianQiKuCun); sellModel.SetCaiGouContractNo(string.Join(";", butContractNoList)); sellModel.SetCaiGouDanWei(string.Join(";", gouXiaoHeTongTaiTou)); sellModel.SetJinXiangShouPiaoDunShu(buyTotalCount); sellModel.SetKuCun(buyTotalCount - sellModel.ProductCount); sellModel.RelativeBusinessIds.AddRange(mappingModelList_Buy.Select(v => v.Id)); sellModel.RelativeBusinessIds.AddRange(mappingModelList_Sell.Select(v => v.Id)); sellModel.RelativeBusinessIds.RemoveAll(v => sellModel.BusinessNo == v); } }
public async Task <IActionResult> PutSellModel([FromRoute] int id, [FromBody] SellModel sellModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != sellModel.SellId) { return(BadRequest()); } _context.Entry(sellModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SellModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <object> AddSell(SellModel request) { EntityContext entityContext = new EntityContext(); var venta = entityContext.Ventas.Add(new Venta() { CantidadProductos = request.SubSellList.Select(e => e.Quantity).Sum(), IdUsuario = request.UserId, Fecha = DateTime.Now, ImporteTotal = request.SubSellList.Select(e => e.Total).Sum() }); entityContext.SaveChanges(); foreach (SubSellModel subSell in request.SubSellList) { entityContext.SubVentas.Add(new SubVentas() { Cantidad = subSell.Quantity, IdProducto = subSell.ProductId, IdVenta = venta.IdVenta, Importe = subSell.Total }); } entityContext.SaveChanges(); return(new { SellId = venta.IdVenta, Status = true }); }
private void CreateOwnerships(SellModel sell) { foreach (SellPositionModel sellPosition in sell.SellPositions) { OwnershipModel ownership = new OwnershipModel(sell.BuyerAccountExtension.AccountId, sellPosition.ConcretePart); OwnershipModel createdOwnership = OwnershipRepo.Create(ownership); } }
private void UpdateSellPositionsSellDates(SellModel sell) { foreach (SellPositionModel sellPosition in sell.SellPositions) { sellPosition.ConcretePart.LastSellDate = sell.SellDate; ConcretePartRepo.Update(sellPosition.ConcretePart.Id, sellPosition.ConcretePart); } }
public ActionResult Create() { var model = new SellModel(); model.FactorNumber = factorService.GetNewFactorNumber(); return(View(model)); }
private void AttachAccountExtension(SellModel sell) { sell.BuyerAccountExtension.LastUsedDate = sell.SellDate; AccountExtensionModel accountExtension = sell.BuyerAccountExtension.Id == 0 ? AccountExtensionRepo.Create(sell.BuyerAccountExtension) : AccountExtensionRepo.Update(sell.BuyerAccountExtension.Id, sell.BuyerAccountExtension); Mapper.Map <AccountExtensionModel, AccountExtensionModel>(accountExtension, sell.BuyerAccountExtension); }
public SellModel Sell([FromBody] SellModel sellModel) { this.sharesController.Sell( sellModel.Amount, sellModel.SharesValue, sellModel.Year); return(sellModel); }
public void Sell_ModelStateValid_Test() { // Arrange Mock <ICategoriesRepository> category = new Mock <ICategoriesRepository>(); category.Setup(m => m.Categories).Returns(new[] { new Category { CategoryId = 1, CategoryName = "Cat1", }, new Category { CategoryId = 1, CategoryName = "Cat2", }, new Category { CategoryId = 1, CategoryName = "Cat3", } }.AsQueryable()); Mock <ILotsRepository> mock = new Mock <ILotsRepository>(); mock.Setup(m => m.Lots).Returns(new[] { new Lot { LotID = 1, Name = "P1", IsCompleted = false }, new Lot { LotID = 2, Name = "P2", IsCompleted = false }, new Lot { LotID = 3, Name = "P3", IsCompleted = false }, new Lot { LotID = 4, Name = "P4", IsCompleted = false }, }.AsQueryable()); SellerController controller = new SellerController(mock.Object, category.Object); controller.ModelState.Clear(); SellModel q = new SellModel { Name = "P1", Files = new List <HttpPostedFileBase>(), Description = "1" }; //Act ActionResult result = controller.Sell(q, "Cat3"); // Assert Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); RedirectToRouteResult routeResult = result as RedirectToRouteResult; Assert.AreEqual(routeResult.RouteValues["action"], "Lot"); }
public async Task <IActionResult> PostSellModel([FromBody] SellModel sellModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.SellListings.Add(sellModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSellModel", new { id = sellModel.SellId }, sellModel)); }
public async Task <IActionResult> Sell() { var _userManager = _serviceProvider.GetRequiredService <UserManager <ApplicationUser> >(); ApplicationUser user = await _userManager.GetUserAsync(User); SellModel model = new SellModel(); model.OwnedAnimals = _db.UserAnimals.Where(ua => ua.UserId == user.Id).Include(ua => ua.Animal).ToList(); model.UnitPrice = getAnimalProducePrice(); return(View(model)); }
public IActionResult SetSell([FromBody] SellModel sellOrder) { var email = HttpContext.User.Claims.ElementAt(0).Value; var id = User.FindFirstValue(ClaimTypes.NameIdentifier); var stock = _context.UserStocks.Where(u => u.Id == id).FirstOrDefault(u => u.Symbol == sellOrder.Symbol); ApplicationUser user = _context.Users.Where(u => u.Id == id).FirstOrDefault(u => u.Cash >= 0); if (stock != null && stock.PurchasedCount > 0) { if (stock.PurchasedCount >= sellOrder.Count) { try { stock.PurchasedCount -= sellOrder.Count; user.Cash += (sellOrder.Count * sellOrder.CurrentPrice); _context.SaveChanges(); return(Ok(new { status = 200, CurrentCash = user.Cash, remaining = stock.PurchasedCount, detail = "Your sell order has been processed." })); } catch (Exception) { return(BadRequest(new { status = 400, detail = "Failure to sell stock." })); } } else { return(BadRequest(new { status = 400, detail = "You do not have enough stock to perform this sell order." })); } } else { return(BadRequest(new { status = 400, detail = "You have not purchased this stock." })); } }
private SellModel SellModelHelper(SqlDataReader rdr) { SellModel newSell = new SellModel(); newSell.SellId = Convert.ToInt32(rdr["id"]); newSell.StockAtSellId = Convert.ToInt32(rdr["stock_at_sell_id"]); newSell.BuyReferenceId = Convert.ToInt32(rdr["buy_reference_id"]); newSell.SharesSold = Convert.ToDouble(rdr["id"]); newSell.PricePerShare = Convert.ToInt32(rdr["id"]); newSell.Profit = Convert.ToDecimal(rdr["profit"]); newSell.SellTimeTicks = Convert.ToInt64(rdr["time_sold"]); return(newSell); }
public IActionResult Sell([FromBody] SellModel sellModel) { this.sharesController.Sell( sellModel.Amount, sellModel.ShareValue, sellModel.Year); var mvts = this.sharesController.GetMovements(); var result = Adapt(mvts); return(this.Ok(result)); }
public void Sell_Post_Validation_Erorr_Test() { //Arrange SellModel q = new SellModel { Name = "P1", Files = new List <HttpPostedFileBase>() }; //Act var context = new ValidationContext(q, null, null); var results = new List <ValidationResult>(); //Assert var isModelStateValid = Validator.TryValidateObject(q, context, results, true); Assert.IsFalse(isModelStateValid); }
public ActionResult AddSell(SellModel Sell) { if (ModelState.IsValid) { SellRepository SellRepo = new SellRepository(); if (SellRepo.AddSell(Sell)) { ViewBag.Message = "Sells details added successfully"; } } return(RedirectToAction("Index", "Home")); }
public ActionResult Sell(SellModel model, string categ) { //var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); if (!ModelState.IsValid) { model.Categories = categoriesRepository.Categories.Select( x => new Categories { Id = x.CategoryId, Name = x.CategoryName }); return(View(model)); } if (categ == null) { ModelState.AddModelError("", Resources.SellerControllerCategory); return(View(model)); } Lot lot = new Lot { Images = new List <Image>(), CurrentPrice = model.MinPrice, Name = model.Name, MinPrice = model.MinPrice, Description = model.Description, EndTime = model.EndTime, IsCompleted = false }; int i = 0; foreach (var img in model.Files) { if (img != null) { lot.Images.Add(new Image { ImageMimeType = img.ContentType, ImageData = new byte[img.ContentLength], }); img.InputStream.Read(lot.Images[i++].ImageData, 0, img.ContentLength); } } var categoryId = Convert.ToInt32(categ); var cat = categoriesRepository.Categories.FirstOrDefault(x => x.CategoryId == categoryId); lot.Category = cat; lotsRepository.Add(lot); return(RedirectToAction("Lot", "Lots", new { lotId = lot.LotID })); }
public ActionResult Create(SellModel model) { if (ModelState.IsValid) { var entity = mapperFacade.CreateMapAndMap <SellModel, Factor>(model); var result = factorService.Add(entity); // return success json result } // return unsuccess json result return(View(model)); }
private SellModel BuildOrderFromManufacturer(string orderId, AccountExtensionModel accountExtension, IEnumerable <SellPositionDto> sellPositions) { SellModel sell = new SellModel(accountExtension); IEnumerable <ConcretePartModel> source = ConcretePartRepo.GetStored(); IEnumerable <ConcretePartModel> order = GetOrderFromSource(sellPositions, source, "part "); foreach (ConcretePartModel concretePart in order) { float price = concretePart.Part.Price.Value * concretePart.SelectedMaterial.PriceCoefficient.Value; SellPositionModel sellPosition = new SellPositionModel(price, concretePart); sell.SellPositions.Add(sellPosition); } return(sell); }
public IActionResult Sell(int?id) { var sellModel = new SellModel(); var balance = accountService.GetAccountBalance(this.User.FindFirstValue(ClaimTypes.NameIdentifier), (int)id); if (balance == null || id == null || id == EUR_ID) { return(RedirectToAction("Index", "Home")); } sellModel.balance = balance; sellModel.balanceName = currencyService.ReadCurrency((int)id).Name; sellModel.exchangeRate = exchangeRateService.ReadExchangeRate((int)id); return(View(sellModel)); }
public ActionResult <SellModel> SellStock(SellModel sellModel) { try { if (sellModel.SharesSold < 0) { return(Forbid()); } SellModel returnModel = buySellDAO.SellStock(sellModel); return(Created($"api/stocks/sell/{returnModel.StockAtSellId}", returnModel)); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
public PaymentInfo CreateManufacturerTradePromise(AddManufacturerSellDto manufacturerSellDto, string callbackEndpoint) { if (manufacturerSellDto.NewAccountExtension == null && manufacturerSellDto.ExisitingAccountExtensionId == null) { throw new NotFoundException("nor old neither new account extension"); } SessionService.CheckSession(manufacturerSellDto.Session); if (manufacturerSellDto.NewAccountExtension != null && manufacturerSellDto.NewAccountExtension.AccountId != manufacturerSellDto.Session.UserId) { throw new ForbiddenException("account owner"); } AccountExtensionModel accountExtension = manufacturerSellDto.ExisitingAccountExtensionId == null || !manufacturerSellDto.ExisitingAccountExtensionId.HasValue ? Mapper.Map <AccountExtensionDto, AccountExtensionModel>(manufacturerSellDto.NewAccountExtension) : AccountExtensionRepo.Get(manufacturerSellDto.ExisitingAccountExtensionId.Value); if (accountExtension == null) { throw new NotFoundException("account extension"); } if (accountExtension.AccountId != manufacturerSellDto.Session.UserId) { throw new ForbiddenException("account owner"); } string orderId = Guid.NewGuid().ToString(); SellModel sellModel = BuildOrderFromManufacturer(orderId, accountExtension, manufacturerSellDto.Positions); Sell sell = new Sell(orderId, sellModel); PendingOrders.Add(orderId, sell); PaymentPrepareModel paymentPrepare = new PaymentPrepareModel(orderId, sellModel.TotalPrice); paymentPrepare.CallbackUrl = callbackEndpoint; paymentPrepare.Expired = sell.Expires; PaymentInfo payment = PaymentService.CreateFromUserPayment(paymentPrepare); sell.PaymentInfo = payment; return(payment); }
public ActionResult <Asset> SellAsset([FromRoute] int id, [FromBody] SellModel sold) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var asset = _context.Asset.Find(id); if (asset == null) { return(BadRequest()); } asset.SoldDate = DateTime.Now; asset.SoldTo = sold.Name; _context.SaveChanges(); return(Ok(asset)); }
public async Task <Response <NoContent> > SellAsync(SellModel sellModel) { (ProductItem ProductItem, MarketItem MarketItem)sell = CreateMarketItem(sellModel); if (sell.MarketItem.IsNull()) { Response <NoContent> response = Response <NoContent> .Fail( statusCode : StatusCodes.Status400BadRequest, isShow : true, path : "[Post] api/trade", errors : "Satma islemi iptal edildi, yeteri kadarda ürününüz mevcut değil" ); return(response); } try { await genericMarketItemRepository.AddAsync(sell.MarketItem); await genericMarketItemRepository.Commit(); sell.ProductItem.UpdateUserId = Guid.Parse(UserStringInfo.SystemUserId); await genericProductItemRepository.UpdateAsync(sell.ProductItem); await genericProductItemRepository.Commit(); Response <NoContent> response = Response <NoContent> .Success(StatusCodes.Status201Created); return(response); } catch { await genericMarketItemRepository.Commit(false); await genericProductItemRepository.Commit(false); Response <NoContent> response = Response <NoContent> .Fail( statusCode : StatusCodes.Status500InternalServerError, isShow : true, path : "[Post] api/trade", errors : "Satma islemi gerçekleşirken bir hata ile karşılaşıldı ve işlem iptal edildi" ); return(response); } }
private void Awake() { if (Instance != null) { Debug.LogWarning("More than one instance of ShopView found."); return; } Instance = this; MoneyCount = _money; shopModel = new BuyModel(_priceModifier, _weaponCountShop, _armorCountShop, _potionCountShop); inventoryModel = new SellModel(_priceModifierInventory, _weaponCountInventory, _armorCountInventory, _potionCountInventory); shopController = gameObject.AddComponent <MouseController>().Initialize(shopModel);//Set the default controller to be the mouse controller inventoryController = gameObject.AddComponent <MouseController>().Initialize(inventoryModel); }
public IActionResult Post(SellModel model) { var tokenResponse = _tokenH.GetToken(); if (tokenResponse.error != null) { return(BadRequest(tokenResponse)); } var sellResponse = _sellH.SellReceiptAccepted(model, tokenResponse.token); if (sellResponse.error != null) { return(BadRequest(sellResponse)); } return(Ok(sellResponse)); }