public BuyItemUseCase(IShopDataAccess shopDataAccess, IShopBuyItemOutput shopBuyItemOutput, ShopEntity shop, InventoryEntity inventory) { _shopDataAccess = shopDataAccess; _shopBuyItemOutput = shopBuyItemOutput; _shop = shop; _inventory = inventory; }
public ActionResult SaveForm(string keyValue, ShopEntity entity) { try { var result = new ReturnMessage(false) { Message = "编辑失败!" }; if (string.IsNullOrWhiteSpace(entity.Name)) { result.Message = "名称不能为空"; return(Json(result)); } if (keyValue == "") { entity.ShopId = Util.Util.NewUpperGuid(); entity.CreateTime = DateTime.Now; entity.CreateId = LoginUser.UserId; ShopBLL.Instance.Add(entity); } else { entity.ShopId = keyValue; ShopBLL.Instance.Update(entity); } return(Success("保存成功")); } catch (Exception ex) { ex.Data["Method"] = "ShopController>>SaveForm"; new ExceptionHelper().LogException(ex); return(Error("保存失败")); } }
void Awake() { var viewPrefab = Instantiate(_viewPrefab); var input = viewPrefab.ShopController; var view = viewPrefab.ShopView; var database = new Database(); var dataAccess = new ShopDataAccess(database); var viewModel = new ShopViewModel(); // var itemCreator = new StandardLazyItemCreator( new List<ItemBluePrint>{new ItemBluePrint{Id = 1, UsageAction =() => { } }} ); var itemCreator = new InternetDependantItemCreator(); var inventory = new InventoryEntity(itemCreator); var prices = dataAccess.ItemPrices(); var resources = new ResourceEntity(); var shop = new ShopEntity(inventory, resources, new ItemPriceData { Prices = prices }); var useCaseInteractor = new BuyItemUseCase(dataAccess, viewModel, shop, inventory); view.Initialize(viewModel); input.Initialize(useCaseInteractor); }
/// <summary> /// 获取去当前门店信息 /// </summary> /// <param name="operate"></param> /// <param name="newMobile"></param> /// <returns></returns> private ShopEntity GetCurrUser(OperateType operate, string newMobile = "") { //获取当前登录信息 ShopEntity currUser = null; if (Session.ContainsKey(ConfigUtil.SystemUserSessionKey)) { var login = Session[ConfigUtil.SystemUserSessionKey] as LoginInfo; currUser = login != null ? login.CurrUserInfo : null; if (operate == OperateType.Dologout) { if (!string.IsNullOrWhiteSpace(newMobile) && currUser != null && currUser.ShopAccount != newMobile) { currUser.ShopAccount = newMobile; } Session[ConfigUtil.SystemUserSessionKey] = null; } } else { if (!string.IsNullOrWhiteSpace(base.AccessToken)) { currUser = SingleInstance <ShopBLL> .Instance.GetShopByAccessToken(base.AccessToken, operate); } } return(currUser); }
/// <summary> /// 更新登录Token /// </summary> /// <param name="shop">店铺信息</param> /// <param name="operateType"></param> /// <param name="access_token">客户端Token</param> /// <returns>新的AccessToken</returns> private string UpdateAccessToken(ShopEntity shop, OperateType operateType, string access_token = "") { CheckShopStatus(shop, operateType); var dbNow = DateTime.Now; switch (operateType) { case OperateType.DoLogin: { if (string.IsNullOrWhiteSpace(shop.AccessToken) || (!shop.AccessToken.Equals(access_token, StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrWhiteSpace(access_token))) { shop.AccessToken = StringUtil.UniqueStr(); shop.ExpiresTime = DateTime.MaxValue; //dbNow.AddHours(12); shop.LastLoginIp = NetUtil.Ip; shop.LastLoginTime = dbNow; shop.ModifyDate = dbNow; service.UpdateEntity(shop); } break; } case OperateType.Dologout: { shop.AccessToken = string.Empty; shop.ModifyDate = dbNow; shop.ExpiresTime = DateTime.MinValue; service.UpdateEntity(shop); break; } } return(shop.AccessToken); }
public static async Task ProcessOrders() { #region تعریف متغییر ها var repository = new Repository(); var shop = new ShopEntity(); var basketOfCustomer = new BasketOfCustomer(); var pendingCustomers = new List <CustomerEntity>(); var successBought = new List <CustomerEntity>(); var report = new Report(); int counterBasketId = 0; #endregion while (true) { // هر یک ثانیه مشتری پاسخ داده می شود Thread.Sleep(1000); // مشتری ای که اولویت دارد اول زن باشد و تعداد کم اقلام می خواهد // و نیز مقدار کمتری اقلام مورد نظر را می خواهد فیلتر کرده ایم var customer = Repository.CustomersList.OrderByDescending(g => g.Gender) .ThenBy(ic => ic.Items.Count()) .ThenBy(ism => ism.Items.Sum(q => q.Qnt)) .FirstOrDefault(); if (customer == null) { continue; } await Task.Run(() => { // بروزرسانی اقلام داخل مغازه shop.ItemsList = Repository.UpdateShopItems; // بررسی موجود بودن اقلام مورد نیاز مشتری bool chackExistItems = repository.ChackExistItems(customer.Items, shop.ItemsList).Result; // بررسی موجود بودن لیست اقلام مشتری در مغازه if (chackExistItems == false) { pendingCustomers.Add(customer); } else { // مشخصات اجناس مورد نظر درخواستی مشتری var basket = basketOfCustomer.BasketImporter(++counterBasketId, customer.Items, DateTime.Now, customer); successBought.Add(customer); report.ShowResult(basket); } // مرحله حذف مشتری از لیست اصلی مشتریان var removeCustomer = Repository.CustomersList.First(c => c.Id == customer.Id); Repository.CustomersList.Remove(removeCustomer); }); } }
public void UpdateShop(ShopEntity shop) { using (ShopEntityContext db = new ShopEntityContext()) { db.Entry(shop).State = EntityState.Modified; db.SaveChanges(); } }
public ActionResult DeleteConfirmed(int id) { ShopEntity shopEntity = db.Shops.Find(id); db.Shops.Remove(shopEntity); db.SaveChanges(); return(RedirectToAction("Index")); }
public static CreateShopResult Create(ShopEntity shopEntity) { return(new CreateShopResult() { Id = shopEntity.Id, Name = shopEntity.Name, Description = shopEntity.Description }); }
void ProcessingReceivedFiles() { Thread receiveThread = new Thread(() => { //TODO: отлавливать выход из ф-ции и перезапускать её foreach (String receivedFile in _interaction.ReceiveXmlMessages()) { if (Properties.Settings.Default.shopId == 0) { var mappingMessage = (ShopInfo)Helper.DeserializeXml(typeof(ShopInfo), receivedFile); if (mappingMessage.Id != 0) { Properties.Settings.Default.shopId = mappingMessage.Id; Properties.Settings.Default.Save(); InsertGood.Dispatcher.Invoke( DispatcherPriority.Background, new Action(() => { InsertGood.IsEnabled = true; }) ); } } else { //сообщение о информации магазина (ShopEntity) от сервера if (_models.Shop.IsEmpty()) { ShopEntity shop = (ShopEntity)Helper.DeserializeXml(typeof(ShopEntity), receivedFile); if (shop != null) { _models.Shop.SetData(shop); InsertGood.Dispatcher.Invoke( DispatcherPriority.Background, new Action(() => { InsertGood.IsEnabled = true; SetStatusMessage("Данные о магазине успешно получены."); }) ); } } else { } } try { File.Delete(receivedFile); } catch (IOException) { } } }); receiveThread.IsBackground = true; receiveThread.Start(); }
IEnumerator HideObjects(ShopEntity shopEntity) { yield return(wait2); if (!(Math.Abs(positionPlayer.position.x) > 100.2f || Math.Abs(positionPlayer.position.z) > 70.2f)) { shopEntity.ParentObjects.SetActive(false); } }
public static async Task LoadServerEntity() { RoleplayContext ctx = Singleton.GetDatabaseInstance(); using (UnitOfWork unit = new UnitOfWork(ctx)) { await BuildingEntity.LoadBuildingsAsync(unit); await AtmEntity.LoadAtmsAsync(unit); await BusEntity.LoadBusAsync(unit); await ShopEntity.LoadShopAsync(unit); await GroupEntity.LoadGroupsAsync(unit); await WarehouseOrderEntity.LoadWarehouseOrdersAsync(); } JobEntity courierJob = new JobEntity(new JobEntityModel() { JobName = "Kurier", VehicleModel = AltV.Net.Enums.VehicleModel.Boxville2, RespawnVehicle = true, Position = new Position(26.1626f, -1300.59f, 29.2124f), RespawnVehiclePosition = new Position(36.9495f, -1283.84f, 29.2799f), RespawnVehicleRotation = new Rotation(0, 0, 1.53369f), JobType = JobType.Courier, MaxSalary = 400 }); courierJob.Create(); JobEntity junkerJob = new JobEntity(new JobEntityModel() { JobName = "Śmieciarz", VehicleModel = AltV.Net.Enums.VehicleModel.Trash, RespawnVehicle = true, Position = new Position(500.334f, -652.009f, 24.8989f), RespawnVehiclePosition = new Position(508.286f, -609.771f, 25.1348f), RespawnVehicleRotation = new Rotation(0, 0, 1.63264f), JobType = JobType.Junker, MaxSalary = 400 }); junkerJob.Create(); JobCenterEntity jobCenter = new JobCenterEntity(new JobCenterModel() { Id = 0, Position = new Position(104.73f, -934.075f, 29.8022f), Jobs = EntityHelper.GetJobs() }); jobCenter.Spawn(); }
public async Task <IActionResult> AddShop(ShopEntity entity) { if (ModelState.IsValid) { var data = await shopService.Add(entity, GetUserSession().user_id); return(Json(data)); } return(Json(ParrNoPass())); }
public static ShopDto Create(ShopEntity shopEntity) { return(new ShopDto() { Description = shopEntity.Description, Name = shopEntity.Name, Id = shopEntity.Id, Open = shopEntity.Open }); }
/// <summary> /// /// </summary> /// <param name="shop"></param> /// <returns>Id магазина в БД</returns> public int InsertShop(ShopEntity shop) { //TODO: сделать проверку на существующий элемент. В этом случае делать Update using (ShopEntityContext db = new ShopEntityContext()) { ShopEntity insertedShop = db.Shops.Add(shop); db.SaveChanges(); return(insertedShop.Id); } }
private OrderItemEntity ProcessSubRequest(CreateOrderItemCommand request,ShopEntity parentShop) { var shopItem = parentShop.Items.FirstOrDefault(o => o.Id.Equals(request.Item)); return new OrderItemEntity { Amount = request.Amount, Item = shopItem, Options = Enumerable.Empty<OrderItemEntity>().ToList() }; }
public async Task <IActionResult> UpdateShop(ShopEntity entity) { if (ModelState.IsValid) { var data = await shopService.UpdateShop(entity); return(Json(data)); } return(Json(ParrNoPass())); }
public ActionResult Edit([Bind(Include = "Id,Name,Phone")] ShopEntity shopEntity) { if (ModelState.IsValid) { db.Entry(shopEntity).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(shopEntity)); }
public ShopEntity GetShopById(int shopId) { ShopEntity result = null; using (ShopEntityContext db = new ShopEntityContext()) { result = db.Shops.Find(shopId); } return(result); }
public ActionResult Create([Bind(Include = "Id,Name,Phone")] ShopEntity shopEntity) { if (ModelState.IsValid) { db.Shops.Add(shopEntity); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(shopEntity)); }
public static int AddShop(ShopEntity shop) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("_business_RegisterShop"); db.AddInParameter(dbCommand, "@ShopBrandID", DbType.Int32, shop.ShopBrandID); db.AddInParameter(dbCommand, "@ShopAreaID", DbType.Int32, shop.ShopAreaID); db.AddInParameter(dbCommand, "@RegisteredCapital", DbType.Decimal, shop.RegisteredCapital); db.AddInParameter(dbCommand, "@ShopName", DbType.String, shop.ShopName); db.AddInParameter(dbCommand, "@RegStatus", DbType.Int32, shop.ShopStatus); db.AddInParameter(dbCommand, "@Address", DbType.String, shop.Address); db.AddInParameter(dbCommand, "@ContractTel", DbType.String, shop.ContactTel); return Convert.ToInt32(db.ExecuteScalar(dbCommand)); }
// GET: ShopEntities/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ShopEntity shopEntity = db.Shops.Find(id); if (shopEntity == null) { return(HttpNotFound()); } return(View(shopEntity)); }
private static ShopEntity ConvertToShopEntity(DataRow dr) { ShopEntity entity = new ShopEntity(); entity.ShopID = Convert.ToInt32(dr["ShopID"]); entity.ShopName = Convert.ToString(dr["ShopName"]).Trim(); entity.ShopAreaID = Convert.ToInt32(dr["ShopAreaID"]); entity.ShopBrandID = Convert.ToInt32(dr["ShopBrandID"]); entity.RegisteredCapital = Convert.ToDecimal(dr["RegisteredCapital"]); entity.Address = Convert.ToString(dr["Address"]).Trim(); entity.ContactTel = Convert.ToString(dr["ContractTel"]).Trim(); entity.Memo = Convert.ToString(dr["Memo"]); return entity; }
public async Task <BaseResult <bool> > UpdateShop(ShopEntity entity) { //判断必须传递参数 if (string.IsNullOrEmpty(entity.shop_name)) { return(new BaseResult <bool>(808, false)); } var isTrue = await shopRepository.UpdateAsync(entity, true, true, c => c.shop_name, c => c.shop_memo, c => c.shop_desc); if (!isTrue) { return(new BaseResult <bool>(201, false)); } return(new BaseResult <bool>(200, true)); }
public async Task <BaseResult <string> > Add(ShopEntity entity, string user_id) { //商品添加,名称可重复,含有商品编号区分 if (string.IsNullOrEmpty(entity.shop_name)) { return(new BaseResult <string>(808, "")); } entity.user_id = user_id; var isTrue = await shopRepository.AddAsync(entity); if (!isTrue) { return(new BaseResult <string>(201, "")); } return(new BaseResult <string>(200, entity.shop_id)); }
public Shop Convert(ShopEntity source) { if (source == null) { return(null); } var result = new Shop { Id = source.RowKey, Name = source.Name, IsActive = source.IsActive, Description = source.Description }; return(result); }
public async Task <CreateShopResult> Handle(CreateShopCommand request, CancellationToken cancellationToken) { var entity = new ShopEntity { Name = request.Name, Description = request.Description }; _dbContext.Shops.Add(entity); await _dbContext.SaveChangesAsync(cancellationToken); await _mediator.Publish(new ShopCreated() { ShopId = entity.Id }, cancellationToken); return(CreateShopResult.Create(entity)); }
protected void btnSave_Click(object sender, EventArgs e) { ShopEntity entity = new ShopEntity(); entity.ShopID = Convert.ToInt32(ViewState["CurShopID"]); entity.ShopAreaID = Convert.ToInt32(ddlShopArea.SelectedValue); entity.ShopBrandID = Convert.ToInt32(ddlShopBrand.SelectedValue); entity.ShopName = txtShopName.Text; entity.Address = txtAddress.Text; entity.ContactTel = txtContractTel.Text; entity.RegisteredCapital = Convert.ToDecimal(txtRegCapital.Text); entity.Memo = txtMemo.Text; ShopManage.UpdateShop(entity); if (!ClientScript.IsClientScriptIncludeRegistered(this.GetType(), "AlertMsg")) ClientScript.RegisterStartupScript(this.GetType(), "AlertMsg", "alert('保存成功!');", true); BindSingleData(entity.ShopID); }
public AddProductWindow(ShopEntity entity) { InitializeComponent(); txtBox_date.Text = entity.PublishDate.ToString(CultureInfo.InvariantCulture); txtBox_description.Text = entity.Description; txtBox_name.Text = entity.Name; txtBox_price.Text = entity.Price.ToString(CultureInfo.InvariantCulture); txtBox_productId.Text = entity.ItemCode; txtBox_publisher.Text = entity.Publisher; txtBox_type.Text = entity.Type.ToString(); lbl_amout.Text = entity.Amout.ToString(); numeric_amout.Minimum = 1; numeric_amout.Maximum = entity.Amout; _entity = entity; }
public static void UpdateShop(ShopEntity entity) { Database db = DatabaseFactory.CreateDatabase(); string sql = "UPDATE TDCar4SalesShop set ShopName=@ShopName,ShopAreaID=@ShopAreaID," + "ShopBrandID=@ShopBrandID,RegisteredCapital=@RegisteredCapital,Address=@Address," + "ContractTel=@ContractTel,Memo=@Memo where ShopID=@ShopID"; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "@ShopID", DbType.Int32, entity.ShopID); db.AddInParameter(dbCommand, "@ShopName", DbType.String, entity.ShopName); db.AddInParameter(dbCommand, "@ShopAreaID", DbType.Int32, entity.ShopAreaID); db.AddInParameter(dbCommand, "@ShopBrandID", DbType.Int32, entity.ShopBrandID); db.AddInParameter(dbCommand, "@RegisteredCapital", DbType.Decimal, entity.RegisteredCapital); db.AddInParameter(dbCommand, "@Address", DbType.String, entity.Address); db.AddInParameter(dbCommand, "@ContractTel", DbType.String, entity.ContactTel); db.AddInParameter(dbCommand, "@Memo", DbType.String, entity.Memo); db.ExecuteNonQuery(dbCommand); }
public ShopEntity Convert(Shop source) { if (source == null) { return(null); } var result = new ShopEntity { PartitionKey = "shops", RowKey = source.Id, Name = source.Name, IsActive = source.IsActive, Description = source.Description }; return(result); }
public void Initialize() { List <ShopEntity> shopEntityList = null; if (this.ShopList != null) { shopEntityList = new List <ShopEntity>(); foreach (var shop in this.ShopList) { ShopEntity shopEntity = new ShopEntity(); shopEntity.IsSelected = true; shopEntity.DownloadStatus = "等待同步"; SystemHelper.AutoCopyData(shopEntity, shop); shopEntityList.Add(shopEntity); } } //绑定店铺 this.treeListShop.DataSource = shopEntityList; }
/// <summary> /// 校验用户状态 /// </summary> /// <param name="currObj">用户信息</param> /// <param name="action">获取信息分类枚举</param> public void CheckShopStatus(ShopEntity currObj, OperateType operateType) { if (operateType == OperateType.DoLogin) { if (currObj == null) { throw new MessageException("此门店不存在!"); } if (currObj.EnabledFlag == EnabledFlagType.Disabled.GetHashCode()) { throw new MessageException(EnabledFlagType.Disabled.GetRemark()); } if (currObj.DeleteFlag == DeleteFlagType.Disabled.GetHashCode()) { throw new MessageException(DeleteFlagType.Disabled.GetRemark()); } } }
private void HandleRemoveFromCart(ShopEntity entity) { var product = _productsCopy.FirstOrDefault(x => entity.ItemCode == x.ItemCode); if (product != null) { product.Amout = product.Amout + entity.Amout; dataGridView1.Refresh(); } else { _productsCopy.Add(entity); _bs.ResetBindings(false); } _cart.Remove(entity); listBox_cart.Items.Remove(entity); UpdateCartSumLabel(); }
private void RegistryShop() { string userID = txtUserID.Text; string userPasswd = txtUserPasswd.Text; string email = txtEmail.Text; if (Membership.FindUsersByName(userID).Count == 0) { MembershipCreateStatus status; MembershipUser msUser = Membership.CreateUser(userID, userPasswd, email, "who are you?", "gaotianle", false, out status); if (status == MembershipCreateStatus.DuplicateUserName) throw new Exception("用户名在系统中已经注册过."); if (status == MembershipCreateStatus.DuplicateEmail) throw new Exception("电子邮件地址在系统中已经注册过."); if (status == MembershipCreateStatus.InvalidPassword) throw new Exception("密码设置不符合要求."); if (status != MembershipCreateStatus.Success) throw new Exception("注册信息不正确."); if (msUser != null) { Roles.AddUserToRole(userID, "ShopUser"); ShopEntity shop = new ShopEntity(); shop.ShopBrandID = Convert.ToInt32(ddlShopBrand.SelectedValue); shop.ShopAreaID = Convert.ToInt32(ddlShopArea.SelectedValue); shop.RegisteredCapital = Convert.ToDecimal(ddlRegCapital.SelectedValue); shop.ShopName = txtShopName.Text; shop.ShopStatus = (int)ShopState.Pending; shop.Address = txtAddress.Text; shop.ContactTel = txtContractTel.Text; int newShopID = ShopManage.AddShop(shop); UserEntity user = new UserEntity(); user.UserID = userID; user.UserRoleID = "ShopUser"; user.BelongShopID = newShopID; user.UserName = userID; user.UserState = (int)UserState.Pending; UserManage.AddUser(user); MailHelper.SendMailMessage("*****@*****.**", email, string.Empty, string.Empty, user.UserName + "申请加入", "请审批"); } } else { throw new Exception("注册失败!"); } }