public ActionResult Edit(Box model) { model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); var repo = new BoxRepository(); bool isexists = repo.IsFieldExists(repo.ConnectionString(), "Box", "BoxName", model.BoxName, "BoxId", model.BoxId); if (!isexists) { var result = new BoxRepository().UpdateBox(model); if (result.BoxId > 0) { TempData["Success"] = "Updated Successfully!"; TempData["BoxRefNo"] = result.BoxRefNo; return(RedirectToAction("Create")); } else { TempData["error"] = "Oops!!..Something Went Wrong!!"; TempData["BoxRefNo"] = null; return(View("Create", model)); } } else { TempData["error"] = "This Name Alredy Exists!!"; TempData["BoxRefNo"] = null; return(View("Create", model)); } }
public ActionResult Edit(int Id) { ViewBag.Title = "Edit"; Box objBox = new BoxRepository().GetBox(Id); return(View("Create", objBox)); }
public ActionResult Delete(Box model) { int result = new BoxRepository().DeleteBox(model); if (result == 0) { TempData["Success"] = "Deleted Successfully!"; TempData["BoxRefNo"] = model.BoxRefNo; return(RedirectToAction("Create")); } else { if (result == 1) { TempData["error"] = "Sorry!! You Cannot Delete This Box It Is Already In Use"; TempData["BoxRefNo"] = null; } else { TempData["error"] = "Oops!!..Something Went Wrong!!"; TempData["BoxRefNo"] = null; } return(RedirectToAction("Create")); } }
// var result = new BoxRepository().InsertBox(model); // if (result.BoxId > 0) // { // TempData["Success"] = "Added Successfully!"; // TempData["BoxRefNo"] = result.BoxRefNo; // return RedirectToAction("Create"); // } // else // { // TempData["error"] = "Oops!!..Something Went Wrong!!"; // TempData["BoxRefNo"] = null; // return View("Create", model); // } //} public ActionResult FillBoxList(int?page) { int itemsPerPage = 10; int pageNumber = page ?? 1; var rep = new BoxRepository(); var List = rep.FillBox(); return(PartialView("BoxListView", List)); }
public void TestCase() { BoxRepository rep = new BoxRepository(); var boxes = rep.GetBoxes(); var distribution = new Distribution(boxes); distribution.BoxDistribution(); }
public static async Task <IActionResult> CreateCart( [HttpTrigger(AuthorizationLevel.Function, "post", Route = "v1/carts")] HttpRequest req, [CosmosDB( databaseName: "smartretailboxmanagement", collectionName: "Terminals", ConnectionStringSetting = "CosmosDbConnectionString")] DocumentClient client, ILogger log) { var parameter = await HttpRequestUtility.GetRequestParameterAsync <CreateCartParameter>(req); var userRepo = new UserRepository(StaticHttpClient.Instance); var user = await userRepo.AuthenticateUserAsync(); if (!user.result.IsSuccess) { return(new UnauthorizedResult()); } var terminalRepo = new TerminalRepository(client); var terminal = await terminalRepo.FindByBoxIdAsync(parameter.BoxId); if (!terminal.result.IsSuccess) { return(ActionResultFactory.CreateError <CreateCartResponse>(terminal.result)); } var cartRepo = new CartRepository(new CartServiceApi(StaticHttpClient.Instance)); var cart = await cartRepo.CreateCartAsync(terminal.info.CompanyCode, terminal.info.StoreCode, terminal.info.TerminalNo, user.info.UserId, user.info.UserName); if (!cart.result.IsSuccess) { return(ActionResultFactory.CreateError <CreateCartResponse>(cart.result)); } var boxRepo = new BoxRepository(client); var updResult = await boxRepo.SetCartIdAsync(parameter.BoxId, parameter.DeviceId, user.info.UserId, cart.info.CartId); if (!updResult.IsSuccess) { return(ActionResultFactory.CreateError <CreateCartResponse>(updResult)); } await BoxUtility.RequestUnLockAsync(terminal.info.BoxId, terminal.info.BoxDeviceId); return(new CreatedResult( string.Empty, new CreateCartResponse { CartId = cart.info.CartId })); }
private void CreateReository <T>() where T : class { if (typeof(IRouteRepository).Equals((typeof(T))) && !RepositoriesCustom.Keys.Contains(typeof(T))) { IRouteRepository repository = new RouteRepository(_dbContext); RepositoriesCustom.Add(typeof(T), repository); } else if (typeof(IClientRepository).Equals((typeof(T))) && !RepositoriesCustom.Keys.Contains(typeof(T))) { IClientRepository repository = new ClientRepository(_dbContext); RepositoriesCustom.Add(typeof(T), repository); } else if (typeof(IProductRepository).Equals((typeof(T))) && !RepositoriesCustom.Keys.Contains(typeof(T))) { IProductRepository repository = new ProductRepository(_dbContext); RepositoriesCustom.Add(typeof(T), repository); } else if (typeof(IDeliveryRepository).Equals((typeof(T))) && !RepositoriesCustom.Keys.Contains(typeof(T))) { IDeliveryRepository repository = new DeliveryRepository(_dbContext); RepositoriesCustom.Add(typeof(T), repository); } else if (typeof(ISaleRepository).Equals((typeof(T))) && !RepositoriesCustom.Keys.Contains(typeof(T))) { ISaleRepository repository = new SaleRepository(_dbContext); RepositoriesCustom.Add(typeof(T), repository); } else if (typeof(IBoxRepository).Equals((typeof(T))) && !RepositoriesCustom.Keys.Contains(typeof(T))) { IBoxRepository repository = new BoxRepository(_dbContext); RepositoriesCustom.Add(typeof(T), repository); } else if (typeof(ITrackingRepository).Equals((typeof(T))) && !RepositoriesCustom.Keys.Contains(typeof(T))) { ITrackingRepository repository = new TrackingRepository(_dbContext); RepositoriesCustom.Add(typeof(T), repository); } }
public void UpdateBoxTest() { Mock <IBoxRepository> boxRep = new Mock <IBoxRepository>(); var box = new BoxRepository(boxRep.Object); Box boxe = new Box(); }
public IEnumerable <Box> Get() { BoxRepository repo = new BoxRepository(); return(repo.GetBoxes()); }
/// <summary> /// 取引終了時の在庫更新を行います。 /// </summary> /// <param name="parameters">パラメーター。</param> /// <param name="client">Cosmos DB クライアント。</param> /// <param name="log">ロガー。</param> /// <returns>非同期の操作を表すタスク。TResult パラメーターの値には、処理の結果が含まれます。</returns> /// <remarks>BOX で付与されたタイムスタンプ順に処理されます。</remarks> private static async Task <(BoxResponse, RepositoryResult)> UpdateClosingStocksAsync( IList <UpdateStocksParameter> parameters, DocumentClient client, ILogger log) { var terminalRepo = new TerminalRepository(client); var boxRepo = new BoxRepository(client); var skuRepo = new SkuRepository(client); var stockRepo = new StockRepository(client); var cartRepo = new CartRepository(new CartServiceApi(StaticHttpClient.Instance)); parameters = parameters .OrderBy(arg => arg.Timestamp) .ToArray(); foreach (var parameter in parameters) { // 在庫を設定します。 var setStocksResult = await stockRepo.SetStocksAsync( parameter.BoxId, "1", parameter.Items.Select(arg => (arg.SkuCode, arg.Quantity)).ToArray()); if (!setStocksResult.IsSuccess) { return(BoxResponseFactory.CreateError <BoxResponse>(setStocksResult), setStocksResult); } // ターミナルを取得します。 (var terminalResult, var terminal) = await terminalRepo.FindByBoxIdAsync(parameter.BoxId); if (!terminalResult.IsSuccess) { return(BoxResponseFactory.CreateError <BoxResponse>(terminalResult), terminalResult); } // BOX を取得します。 (var boxResult, var box) = await boxRepo.FindByBoxIdAsync(parameter.BoxId); if (!boxResult.IsSuccess) { return(BoxResponseFactory.CreateError <BoxResponse>(boxResult), boxResult); } // 取引開始時と比較して、在庫数に差異がある BOX 商品を取得します。 (var stockDifferencesResult, var stockReferrences) = await stockRepo.GetStockDifferencesAsync(parameter.BoxId); if (!stockDifferencesResult.IsSuccess) { return(BoxResponseFactory.CreateError <BoxResponse>(stockDifferencesResult), stockDifferencesResult); } // BOX 商品を POS 商品に変換し、 // 取引開始時と比較して、在庫数に差異がある POS 商品を抽出します。 var items = stockReferrences .Select(arg => (arg.SkuCode, arg.Quantity)) .ToArray(); (var posItemsResult, var posItems) = await BoxItemsToPosItemsAsync(terminal.CompanyCode, terminal.StoreCode, items, skuRepo); if (!posItemsResult.IsSuccess) { return(BoxResponseFactory.CreateError <BoxResponse>(posItemsResult), posItemsResult); } var changedPosItems = posItems .Where(arg => arg.Quantity != 0) .Select(arg => (arg.ItemCode, 0 < arg.Quantity ? 1 : 2, Math.Abs(arg.Quantity))) .ToArray(); if (changedPosItems.Any()) { // 取引を確定します。 var subtotalResult = await cartRepo.SubtotalAsync(box.CartId, changedPosItems); if (!subtotalResult.IsSuccess) { return(BoxResponseFactory.CreateError <BoxResponse>(subtotalResult), subtotalResult); } var createPaymentResult = await cartRepo.CreatePaymentsAsync(box.CartId, new[] { ("01", 0M) });
public BoxController() { this.boxrepository = new BoxRepository(new BoxdbEntities(), new ProductdbEntities()); }
public LogisticBiz() { repo = new BoxRepository(); }
public BoxService(ApplicationDbContext context) { repository = new BoxRepository(context); }