private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) { if (grcShop.DataSource == null || grvShop.RowCount == 0) { return; } ShopDto shop = grvShop.GetRow(e.RowHandle) as ShopDto; if (e.Column == gcShopCode && shop.StatusType != 'I') { e.Appearance.BackColor = Color.Gray; } }
public IHttpActionResult Get([FromUri] Guid shopId) { var shop = shoppingEntities.Shops.FirstOrDefault(t => t.Id == shopId); if (shop == null) { throw new BadRequestException("Không tìm thấy Shop"); } var shopDto = new ShopDto(shop); return(Ok(shopDto)); }
private void btnShopCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { Shop_Popup pop = new Shop_Popup("", "", false); pop.ShowDialog(); ShopDto dto = pop.Shopdto; if (dto != null) { btnShopCode.Text = dto.ShopCode; txtShopName.Text = dto.ShopName; } }
private void btnShopCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { Shop_Popup pop = new Shop_Popup("", "", false, CommonHandler.GetComboBoxSelectedValue(cboProject).ToString(), UserInfoDto, "RecheckUser"); pop.ShowDialog(); ShopDto dto = pop.Shopdto; if (dto != null) { btnShopCode.Text = dto.ShopCode; txtShopName.Text = dto.ShopName; } }
public async Task <ActionResult <Shop> > PostShop(ShopDto shop) { if (shop.OwnerId != AuthenticatedUserId()) { return(Unauthorized("Shop does not belong to you")); } await _context.Shops.AddAsync(_mapper.Map <Shop>(shop)); await _context.SaveChangesAsync(); return(CreatedAtAction("GetShop", new { id = shop.Id }, shop)); }
public async Task <List <Shop> > GetAllAsync(ShopDto dto, CancellationToken token = default) { using (var db = new GuoGuoCommunityContext()) { var list = await db.Shops.Where(x => x.IsDeleted == false).ToListAsync(token); if (!string.IsNullOrWhiteSpace(dto.Name)) { list = list.Where(x => x.Name.Contains(dto.Name)).ToList(); } return(list); } }
public IShopDto GetById(string id) { if (!UserHasRoles(ApplicationRoles.ShopView, ApplicationRoles.ShopEdit, ApplicationRoles.ShopCreate)) { return(null); } Guid shopGuid = Guid.Parse(id); ShopDto result = GetShops(shopGuid)?.FirstOrDefault(); // Return. return(result); }
public void InsertShops(List <string[]> packetList) { var shopCounter = 0; var shops = new List <ShopDto>(); var mapnpcdb = _mapNpcDao.LoadAll().ToList(); var shopdb = _shopDao.LoadAll().ToList(); foreach (var currentPacket in packetList.Where(o => (o.Length > 6) && o[0].Equals("shop") && o[1].Equals("2")) ) { var npcid = short.Parse(currentPacket[2]); var npc = mapnpcdb.FirstOrDefault(s => s.MapNpcId == npcid); if (npc == null) { continue; } var name = new StringBuilder(); for (var j = 6; j < currentPacket.Length; j++) { name.Append($"{currentPacket[j]}"); if (j != currentPacket.Length - 1) { name.Append(" "); } } var shop = new ShopDto { Name = name.ToString(), MapNpcId = npc.MapNpcId, MenuType = byte.Parse(currentPacket[4]), ShopType = byte.Parse(currentPacket[5]) }; if ((shopdb.FirstOrDefault(s => s.MapNpcId == npc.MapNpcId) != null) || shops.Any(s => s.MapNpcId == npc.MapNpcId)) { continue; } shops.Add(shop); shopCounter++; } _shopDao.InsertOrUpdate(shops); _logger.Information(LogLanguage.Instance.GetMessageFromKey(LogLanguageKey.SHOPS_PARSED), shopCounter); }
public override void AddRowButtonClick() { //if (CommonHandler.GetComboBoxSelectedValue(cboSaleBigArea) == null || string.IsNullOrEmpty(CommonHandler.GetComboBoxSelectedValue(cboSaleBigArea).ToString())) //{ // CommonHandler.ShowMessage(MessageType.Information, "请先选择一个大区"); // return; //} ShopDto shop = new ShopDto(); shop.SaleBig = ""; shop.AfterBig = ""; shop.UseChk = true; dataHandler.AddRow(shop); }
public IHttpActionResult Put([FromUri] Guid shopId, [FromBody] ShopDto shopDto) { Shop shop = shoppingEntities.Shops.FirstOrDefault(t => t.Id == shopId); if (shop == null) { throw new BadRequestException("Không tìm thấy Shop"); } shopDto.ToModel(shop); shoppingEntities.SaveChanges(); return(Ok(new ShopDto(shop))); }
public MyResult <object> PubShop([FromBody] ShopDto model) { if (string.IsNullOrEmpty(base.TokenModel.Id.ToString()) || base.TokenModel.Id < 0) { return(new MyResult <object>(-1, "请检查是否登录")); } if (!string.IsNullOrEmpty(model.LogoPic)) { var fileName = DateTime.Now.GetTicket().ToString(); var url = ImageHandlerUtil.SaveBase64Image(model.LogoPic, $"{fileName}.png", $"{Constants.Shop_Logo_Path}/{base.TokenModel.Id}"); model.LogoPic = url; } model.UserId = base.TokenModel.Id; return(SetingService.AddShop(model)); }
public void WhenShopNameDoesntExistThenSuccessfullActionResultIsReturned() { var repositoryMock = new Mock <IShopRepository>(); repositoryMock.Setup(r => r.GetShopByName("shopName")).Returns((Shop)null); var shopConfigurationService = new ShopConfigurationService(repositoryMock.Object); var shopDto = new ShopDto() { Name = "shopName" }; ServiceActionResult serviceActionResult = shopConfigurationService.AddNewShop(shopDto); serviceActionResult.Status.Should().Be(ActionStatus.Successfull); }
public IHttpActionResult CreateShop([FromBody] ShopViewModel shop) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var _shopDto = new ShopDto { Name = shop.Name, Address = shop.Address, StartTime = shop.StartTime, EndTime = shop.EndTime }; this._shopService.Create(_shopDto); return(CreatedAtRoute("DefaultApi", new { }, shop)); }
public ActionResult EditShop(ShopViewModel shop) { if (!ModelState.IsValid) { ViewBag.Error = $"Shop {shop.ShopName} cannot be edited"; return(RedirectToAction("AdminShopList")); } ShopDto shopDto = shop.Map(); ServiceActionResult editResult = _shopConfigurationClient.EditShop(shopDto); if (editResult.Status != ActionStatus.Successfull) { ViewBag.Error = editResult.Reason; } return(RedirectToAction("AdminShopList")); }
public void WhenAddToDatabaseThrowExceptionThenStatusWithExceptionIsReturned() { var shopRepository = new Mock <IShopRepository>(); shopRepository.Setup(r => r.GetShopByName(It.IsAny <string>())).Returns((Shop)null); shopRepository.Setup(r => r.AddToDatabase(It.IsAny <Shop>())).Throws <Exception>(); var shopConfigurationService = new ShopConfigurationService(shopRepository.Object); var shopDto = new ShopDto() { Name = "shopName" }; ServiceActionResult serviceActionResult = shopConfigurationService.AddNewShop(shopDto); serviceActionResult.Status.Should().Be(ActionStatus.WithException); }
private void gridView1_ShowingEditor(object sender, CancelEventArgs e) { ShopDto shop = grvShop.GetRow(grvShop.FocusedRowHandle) as ShopDto; if (grvShop.FocusedColumn == gcShopCode) { if (shop.StatusType != 'I') { e.Cancel = true; } else { e.Cancel = false; } } }
private void SearchShop() { DataSet ds = service.SearchShop("", ""); List <ShopDto> list = new List <ShopDto>(); if (ds.Tables.Count > 0) { for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { ShopDto shop = new ShopDto(); shop.ShopCode = ds.Tables[0].Rows[j]["ShopCode"].ToString(); shop.ShopName = ds.Tables[0].Rows[j]["ShopName"].ToString(); list.Add(shop); } } grcShop.DataSource = list; }
public void Update(ShopDto item) { if (this._tuow.Shops.Get(item.Id) == null) { throw new ValidationException("Shop is not found", " "); } var _shop = new Shop { Id = item.Id, Name = item.Name, Address = item.Address, StartTime = item.StartTime, EndTime = item.EndTime }; this._tuow.Shops.Update(_shop); this._tuow.Save(); }
public MyResult <object> DelShop(ShopDto model) { MyResult result = new MyResult(); if (!model.Id.HasValue) { return(result.SetStatus(ErrorCode.InvalidData, "id 非法")); } var shop = base.First <Shop>(predicate => predicate.Id == model.Id); if (shop != null) { base.Delete(shop, true); } result.Data = true; return(result); }
public ShopDto ShopsById(long id) { ShopDto ShopDto = new ShopDto(); using (EAharaDB context = new EAharaDB()) { var acctype = context.Shops.FirstOrDefault(x => x.IsActive == true && x.Id == id); if (acctype != null) { ShopDto.Id = acctype.Id; ShopDto.ShopCategoryId = acctype.ShopCategoryId; ShopDto.Name = acctype.Name; ShopDto.Description = acctype.Description; ShopDto.TagLine = acctype.TagLine; ShopDto.Address = acctype.Address; ShopDto.OpeningHours = acctype.OpeningHours; ShopDto.Preference = acctype.Preference; ShopDto.CommissionPercentage = acctype.CommissionPercentage; ShopDto.MobileNo = acctype.MobileNo; ShopDto.MobileNo2 = acctype.MobileNo2; ShopDto.MobileNo3 = acctype.MobileNo3; ShopDto.Image = acctype.Image; ShopDto.AverageCost = acctype.AverageCost; ShopDto.Order = acctype.Order; ShopDto.AverageRating = acctype.AverageRating; ShopDto.Cuisines = acctype.Cuisines; ShopDto.DeliveryTime = acctype.DeliveryTime; ShopDto.IsActive = acctype.IsActive; ShopDto.DeliveryCharge = acctype.DeliveryCharge; ShopDto.StartTime = acctype.StartTime; ShopDto.EndTime = acctype.EndTime; ShopDto.Lat = acctype.Lat; ShopDto.Lng = acctype.Lng; ShopDto.DeliveryRange = acctype.DeliveryRange; ShopDto.LocationId = acctype.LocationId; ShopDto.Location = new LocationDto { Id = acctype.Location != null ? acctype.Location.Id : 0, Name = acctype.Location != null ? acctype.Location.Name : "", }; } } return(ShopDto); }
public ActionResult Shop([Bind(Prefix = "ShopDto")] ShopDto dto) { var medicine = _pharmacyService.GetMedicineById(_context, dto.IdMedicine); if (dto.DeliveryMethod == "Wysylka" && medicine.StorageMethod == "Warunki chlodnicze") { ViewBag.Error = "Odbiór tylko osobisty, ponieważ lek jest przechowywany w warunkach chlodniczych"; var viewModel = _pharmacyService.GetAllMedicineViewModel(_context); return(View(viewModel)); } else if (dto.DeliveryMethod == "Wysylka" && medicine.Perscription == true) { ViewBag.Error = "Odbiór tylko osobisty, ponieważ jest potrzebne okazanie recepty"; var viewModel = _pharmacyService.GetAllMedicineViewModel(_context); return(View(viewModel)); } return(View("Successful")); }
private List <ShopDto> SearchAllShopByProjectCode(string projectCode) { DataSet ds = service.SearchShopByProjectCode(projectCode); List <ShopDto> shopDtoList = new List <ShopDto>(); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ShopDto shopDto = new ShopDto(); shopDto.ShopCode = Convert.ToString(ds.Tables[0].Rows[i]["ShopCode"]); shopDto.ShopName = Convert.ToString(ds.Tables[0].Rows[i]["ShopName"]); shopDtoList.Add(shopDto); } } grcShop.DataSource = shopDtoList; return(shopDtoList); }
public async Task GetShops_Positive() { //Arrange List <Shop> ShopObjList = new List <Shop>(); List <ShopDto> ShopList = new List <ShopDto>(); Shop ShopObj = new Shop() { ShopID = 1, ShopName = "Nike", ShopCity = "Halifax", ShopCountry = "Canada", ShopState = "NS", ShopStreet = "2001 Brunswick", ShopZip = "B3J3J7" }; ShopDto Shop = new ShopDto() { ShopID = 1, ShopName = "Nike", ShopCity = "Halifax", ShopCountry = "Canada", ShopState = "NS", ShopStreet = "2001 Brunswick", ShopZip = "B3J3J7" }; ShopList.Add(Shop); ShopObjList.Add(ShopObj); //Mock mockShopiMaxRepo.Setup(x => x.GetShops()).ReturnsAsync(ShopObjList); mockMapperRepo.Setup(mock => mock.Map <IEnumerable <ShopDto> >(It.IsAny <IEnumerable <Shop> >())).Returns(ShopList); //Result IActionResult result = await controllerObj.GetShops(); OkObjectResult Objresult = result as OkObjectResult; List <ShopDto> ShopDisplay = Objresult.Value as List <ShopDto>; //Assert Assert.IsTrue(ShopDisplay[0].ShopID == Shop.ShopID); }
public void InsertShops(List <string[]> packetList) { int shopCounter = 0; var shops = new List <ShopDto>(); foreach (var currentPacket in packetList.Where(o => o.Length > 6 && o[0].Equals("shop") && o[1].Equals("2"))) { short npcid = short.Parse(currentPacket[2]); var npc = DaoFactory.MapNpcDao.FirstOrDefault(s => s.MapNpcId == npcid); if (npc == null) { continue; } string name = string.Empty; for (int j = 6; j < currentPacket.Length; j++) { name += $"{currentPacket[j]} "; } name = name.Trim(); var shop = new ShopDto { Name = name, MapNpcId = npc.MapNpcId, MenuType = byte.Parse(currentPacket[4]), ShopType = byte.Parse(currentPacket[5]) }; if (DaoFactory.ShopDao.FirstOrDefault(s => s.MapNpcId == npc.MapNpcId) != null || shops.Any(s => s.MapNpcId == npc.MapNpcId)) { continue; } shops.Add(shop); shopCounter++; } IEnumerable <ShopDto> shopDtos = shops; DaoFactory.ShopDao.InsertOrUpdate(shopDtos); _logger.Information(LogLanguage.Instance.GetMessageFromKey(LogLanguageKey.SHOPS_PARSED), shopCounter); }
public void Generate(string filePath) { var shopService = ChickenContainer.Instance.Resolve <IShopService>(); var mapNpcService = ChickenContainer.Instance.Resolve <IMapNpcService>(); Dictionary <long, MapNpcDto> npcs = mapNpcService.Get().ToDictionary(s => s.Id, s => s); Dictionary <long, ShopDto> shops = shopService.Get().ToDictionary(s => s.Id, s => s); string[] splitters = { "\r\n", "\r", "\n" }; string[] lines = File.ReadAllText(filePath, Encoding.Default).Split(splitters, StringSplitOptions.RemoveEmptyEntries); int counter = 0; int tmpp = 0; foreach (string line in lines.Where(s => s.StartsWith("shop") && !s.StartsWith("shopping") && !s.StartsWith("shopclose"))) { try { tmpp++; string[] currentPacket = line.Split('\t', ' '); long mapnpcid = long.Parse(currentPacket[2]); if (!npcs.ContainsKey(mapnpcid) || _shops.Any(s => s.MapNpcId == mapnpcid) || shops.Any(s => s.Value.MapNpcId == mapnpcid)) { continue; } var shop = new ShopDto { Name = string.Join(" ", currentPacket.Skip(6)).Trim(), MapNpcId = mapnpcid, MenuType = byte.Parse(currentPacket[4]), ShopType = byte.Parse(currentPacket[5]) }; counter++; _shops.Add(shop); } catch (Exception e) { Log.Error("[PARSE]", e); Log.Warn(line); } } shopService.Save(_shops); }
private void Search() { DataSet ds = webService.ShopSearch(CommonHandler.GetComboBoxSelectedValue(cboProjects).ToString(), txtShopCode.Text.Trim(), txtShop.Text.Trim()); List <ShopDto> shoplist = new List <ShopDto>(); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ShopDto shop = new ShopDto(); shop.AreaCode = Convert.ToString(ds.Tables[0].Rows[i]["AreaCode"]); shop.ShopCode = Convert.ToString(ds.Tables[0].Rows[i]["ShopCode"]); shop.ShopName = Convert.ToString(ds.Tables[0].Rows[i]["ShopName"]); shoplist.Add(shop); } } grcShop.DataSource = shoplist; }
private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) { if (grcShop.DataSource == null || grvShop.RowCount == 0) { return; } ShopDto shop = grvShop.GetRow(e.RowHandle) as ShopDto; if (e.Column == gcShopCode && shop.StatusType != 'I' ) { e.Appearance.BackColor = CommonHandler.GetReadOnlyColor(); e.Appearance.ForeColor = Color.Black; } if (e.Column == gcInDateTime || e.Column == gcInUserId) { e.Appearance.BackColor = CommonHandler.GetReadOnlyColor(); e.Appearance.ForeColor = Color.Black; } }
/// <summary> /// 更新店铺开启的活动 /// </summary> /// <param name="dto"></param> /// <param name="token"></param> /// <returns></returns> public async Task <bool> UpdateShopActivitySign(ShopDto dto, CancellationToken token = default) { using (var db = new GuoGuoCommunityContext()) { if (!Guid.TryParse(dto.Id, out var uid)) { throw new NotImplementedException("商户信息不正确!"); } var shop = await db.Shops.Where(x => x.Id == uid).FirstOrDefaultAsync(token); if (shop == null) { throw new NotImplementedException("该商户不存在!"); } shop.ActivitySign = dto.ActivitySign; shop.LastOperationTime = dto.OperationTime; shop.LastOperationUserId = dto.OperationUserId; return(await db.SaveChangesAsync(token) > 0); } }
public async Task GenerateItemsAsync(ShopDto shop, int minLevel, int maxLevel) { _random = new Random(); using (var uow = UnitOfWorkProvider.Create()) { for (var i = minLevel; i <= maxLevel; i++) { for (var j = 0; j < 4; j++) { var result = GenerateItemBasedOnLevel(i, shop.ArmorClass); var item = result.Item1; var attr = result.Item2; attr.Id = Guid.NewGuid(); item.ShopId = shop.Id; item.Attributes = attr; item.Id = _itemService.Create(item); } } await uow.Commit(); } }
public IHttpActionResult EditShop([FromBody] ShopViewModel shop) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var _shopDto = new ShopDto { Id = shop.Id, Name = shop.Name, Address = shop.Address, StartTime = shop.StartTime, EndTime = shop.EndTime }; this._shopService.Update(_shopDto); return(Ok()); } catch (ValidationException ex) { ModelState.AddModelError(ex.Property, ex.Message); return(NotFound()); } }