partial void Merge(Miniature entity, ItemDTO dto, object state) { if (dto.MiniPet != null) { entity.MiniatureId = dto.MiniPet.MiniPetId; } }
partial void Merge(Transmutation entity, ItemDTO dto, object state) { if (dto.Consumable.Skins == null) { entity.SkinIds = new List<int>(0); } else { var values = new List<int>(dto.Consumable.Skins.Length); values.AddRange(dto.Consumable.Skins); entity.SkinIds = values; } }
private void OnItemBtn() { Dropdown dd = ItemDropdown.gameObject.GetComponent <Dropdown>(); ItemItem itemConfig = Global.gApp.gGameData.GetItemDataByName(dd.captionText.text); if (itemConfig != null) { ItemDTO itemDTO = new ItemDTO(itemConfig.id, ItemNumSlider.slider.value, BehaviorTypeConstVal.OPT_GM); GameItemFactory.GetInstance().AddItem(itemDTO); Global.gApp.gMsgDispatcher.Broadcast <string>(MsgIds.ShowGameTipsByStr, string.Format("成功添加{0}个\"{1}\"", itemDTO.num, dd.captionText.text)); } else { Global.gApp.gMsgDispatcher.Broadcast <string>(MsgIds.ShowGameTipsByStr, string.Format("不支持添加\"{0}\"", dd.captionText.text)); } }
public ItemDTO Get(int id) { ItemDTO retValue = null; using (var context = new DataAccessContext()) { var item = (from n in context.Items where n.ID == id select n).FirstOrDefault(); retValue = retValue.DTOConvert(item); retValue.StatusMessage = $"Found Item"; } return(retValue); }
public bool DeleteItem(Connection conn, ItemDTO sp) { string queryString = "update Item set isDeleted=true where id=" + sp.ID; conn.cmd.CommandText = queryString; try { conn.cmd.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(false); } return(true); }
public ItemDTO GetItem(int id) { ItemDTO item = _itemLogc.GetItemById(id); _logger.LogInformation($"Start: Getting OrderItem {item}"); if (item == null) { _logger.LogInformation($"Somthing went wrong GetItem {id}"); throw new ArgumentException($"Cannot get item by item id : {id}", nameof(id)); } _logger.LogInformation($"Complete: Getting OrderItem {id}, {item}"); return(item); }
partial void Merge(SalvageTool entity, ItemDTO dto, object state) { var tool = dto.Tool; if (tool == null) { return; } int charges; if (int.TryParse(tool.Charges, out charges)) { entity.Charges = charges; } }
partial void Merge(CraftingRecipeUnlocker entity, ItemDTO dto, object state) { var consumableDto = dto.Consumable; if (consumableDto == null) { return; } int recipeId; if (int.TryParse(consumableDto.RecipeId, out recipeId)) { entity.RecipeId = recipeId; } }
public ItemDTO CreateItem(ItemDTO item) { using (SqlConnection conn = new SqlConnection(this.connectionString)) using (SqlCommand comm = conn.CreateCommand()) { comm.CommandText = "INSERT into Items (Title, Price, av_amount) " + "output INSERTED.ItemID values (@title, @price, @av_amount)"; comm.Parameters.Clear(); comm.Parameters.AddWithValue("title", item.Title); comm.Parameters.AddWithValue("price", item.Price); comm.Parameters.AddWithValue("av_amount", item.av_amount); conn.Open(); item.ItemID = Convert.ToInt64(comm.ExecuteScalar()); return(item); } }
partial void Merge(DyeUnlocker entity, ItemDTO dto, object state) { var consumable = dto.Consumable; if (consumable == null) { return; } int colorId; if (int.TryParse(consumable.ColorId, out colorId)) { entity.ColorId = colorId; } }
async void AddItem_Clicked(object sender, EventArgs e) { ItemDTO newitem = new ItemDTO(); newitem.ItemName = newItemName.Text; newitem.ForSale = false; newitem.UserCollectionsId = CurrentCollection.Id; if (newitem != null || newitem.ItemName != "") { service.PostNewItemToDB(newitem).Wait(); var vUpdatedPage = new ItemPage(CurrentCollection, SignedInUser); Navigation.InsertPageBefore(vUpdatedPage, this); await Navigation.PopAsync(); } }
public async Task <ActionResult <ItemDTO> > CreateTodoItem(ItemDTO itemDTO) { var item = new Item { IsComplete = itemDTO.IsComplete, Name = itemDTO.Name }; _context.Items.Add(item); await _context.SaveChangesAsync(); return(CreatedAtAction( nameof(GetItem), new { id = item.Id }, ItemToDTO(item))); }
public static Item MapToEntity(ItemDTO obj) { return(new Item { Id = obj.Id, Title = obj.Title, StartTime = obj.StartTime, StartingPrice = obj.StartingPrice, Description = obj.Description, UserId = obj.UserId, EndTime = obj.EndTime, MinIncrease = obj.MinIncrease, CategoryId = obj.CategoryId, Image = obj.Image }); }
public ItemDTO CreateItem(ItemDTO item) { using (SqlConnection conn = new SqlConnection(this.connectionString)) using (SqlCommand comm = conn.CreateCommand()) { comm.CommandText = "insert into Item (Name, Price, OnStock) output INSERTED.ItemID values (@Name, @Price, @OnStock)"; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@Name", item.Name); comm.Parameters.AddWithValue("@Price", item.Price); comm.Parameters.AddWithValue("@OnStock", item.OnStock); conn.Open(); item.ItemID = Convert.ToInt32(comm.ExecuteScalar()); return(item); } }
/// <summary> /// Add new SanPham to Database /// </summary> /// <param name="sp"></param> public void AddSanPham(Connection conn, ItemDTO sp) { this.listSanPham = this.itemDAO.AddItem(conn, sp); if (this.listSanPham == null) { MessageBox.Show( "Có lỗi xảy ra trong quá trình thêm dữ liệu, vui lòng thử lại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { this.LoadSanPham(conn); } }
public bool UpdateItem(ItemDTO itemToUpdate) { _validator.ValidateAndThrow(itemToUpdate); var item = _context.Item.FirstOrDefault(f => f.Id == itemToUpdate.Id); if (item != null) { var update = _mapper.Map(itemToUpdate, item); item.LastModifiedOn = DateTime.Now; _context.Update(item); _context.SaveChanges(); return(true); } return(false); }
public List <ItemDTO> AddItem(Connection conn, ItemDTO sp) { List <ItemDTO> result = new List <ItemDTO>(); string queryString = "insert into Item(name, type, amount, minimum, provider, isRequestImport, isDeleted) " + "values('" + sp.name + "', '" + sp.type + "', " + sp.amount + ", " + sp.minimum + ", '" + sp.provider + "', false, false)"; conn.cmd.CommandText = queryString; try { conn.cmd.ExecuteNonQuery(); } catch (Exception ex) { throw (ex); } queryString = "select* from Item order by id desc limit 1"; conn.cmd.CommandText = queryString; using (DbDataReader reader = conn.cmd.ExecuteReader()) { if (!reader.HasRows) { return(null); } else { while (reader.Read()) { ItemDTO temp = new ItemDTO( reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetInt64(3), reader.GetInt64(4), reader.GetString(5), reader.GetBoolean(6)); result.Add(temp); } } } return(result); }
public void SendItem(long characterId, MallItem item) { if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId))) { return; } ItemDTO dto = DAOFactory.ItemDAO.LoadById(item.ItemVNum); if (dto != null) { int limit = 99; if (dto.Type == InventoryType.Equipment || dto.Type == InventoryType.Miniland) { limit = 1; } do { MailDTO mailDTO = new MailDTO { AttachmentAmount = (byte)(item.Amount > limit ? limit : item.Amount), AttachmentRarity = item.Rare, AttachmentUpgrade = item.Upgrade, AttachmentVNum = item.ItemVNum, Date = DateTime.Now, EqPacket = string.Empty, IsOpened = false, IsSenderCopy = false, Message = string.Empty, ReceiverId = characterId, SenderId = characterId, Title = "NOSMALL" }; DAOFactory.MailDAO.InsertOrUpdate(ref mailDTO); AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(mailDTO.ReceiverId)); if (account?.ConnectedWorld != null) { account.ConnectedWorld.MailServiceClient.GetClientProxy <IMailClient>().MailSent(mailDTO); } item.Amount -= limit; } while (item.Amount > 0); } }
void Item() { List <CategoryDropdownlistDTO> list = new CategoryBL().SelectDropdownData(); int cateIndex = list.Count - 1; DateTime date = DateTime.Now; for (int i = 0; i < 100000; i++) { if (cateIndex == 0) { cateIndex = list.Count - 1; } ItemDTO dto = new ItemDTO(); dto.code = "Mã_" + i; dto.name = "Tên_" + i; dto.category_id = list[cateIndex--].id; dto.inventory_measure_id = 0; dto.manufacture_size_measure_id = 0; dto.manufacture_weight_measure_id = 0; dto.dangerous = i % 2 == 0; dto.specification = "Specification_" + i; dto.description = "Mô tả_" + i; date = date.AddDays(1); dto.discontinued_datetime = date; dto.inventory_expired = i; dto.inventory_standard_cost = i; dto.inventory_list_price = i; dto.manufacture_day = i; dto.manufacture_make = i % 2 != 0; dto.manufacture_tool = i % 2 != 0; dto.manufacture_finished_goods = i % 2 == 0; dto.manufacture_size = "Size_" + i; dto.manufacture_weight = "Weight_" + i; dto.manufacture_style = "Style_" + i; dto.manufacture_class = "Class_" + i; dto.manufacture_color = "Color_" + i; dto.created_by = 123; dto.updated_by = 123; new ItemBL().InsertData(dto); } }
public void Update_Company_Stock_Returns_BasketDto() { var company = new CompanyDTO(); var item = new ItemDTO(); var addedItem = new AddedItemDTO { Company = company, Item = item, }; addedItem.Company.Id = 1; addedItem.Item.Id = 1; var basketDtoList = new List <BasketDTO>(); var basketDto = new BasketDTO { Id = 1, ItemId = 1, ItemCount = 1 }; basketDtoList.Add(basketDto); var mockMapper = new MapperConfiguration(cfg => { cfg.CreateMap <BasketDTO, Basket>().ReverseMap(); }); var mapper = mockMapper.CreateMapper(); var options = new DbContextOptionsBuilder <ApiContext>() .UseInMemoryDatabase("company_stock_update_test_db") .Options; using (var context = new ApiContext(options)) { context.LoadUserBasketTestData(1); var companyStock = context.CompanyItem.First(s => s.CompanyId == addedItem.Company.Id && s.ItemId == addedItem.Item.Id).Stock; var repository = new ItemRepository(context); repository.UpdateCompanyStock(addedItem); var companyStockUpdated = context.CompanyItem.First(s => s.CompanyId == addedItem.Company.Id && s.ItemId == addedItem.Item.Id).Stock; Assert.Equal(companyStock - 1, companyStockUpdated); } }
/// <summary> /// Gets the specified identifier. /// </summary> /// <param name="Id">The identifier.</param> /// <returns></returns> public ItemDTO Get(long Id) { ItemDTO item = null; try { ItemSchema.Item itemDb = this.repository.GetIQueryable <ItemSchema.Item>().Where <ItemSchema.Item>(a => a.Id == Id).FirstOrDefault <ItemSchema.Item>(); item = AutoMapperConf.AutoMapperConf.Instance.Mapper.Map <ItemDTO>(itemDb); } catch (Exception ex) { LogHelper.LogException(ex, MethodBase.GetCurrentMethod().Name); } return(item); }
partial void Merge(Food entity, ItemDTO dto, object state) { var consumable = dto.Consumable; if (consumable == null) { return; } entity.Effect = consumable.Description; double duration; if (double.TryParse(consumable.Duration, out duration)) { entity.Duration = TimeSpan.FromMilliseconds(duration); } }
public bool AddItem(ItemDTO pItemDTO) { using (db = new MobileEntities()) { ITEM item = DALUtilitiesMethod.ToItem(pItemDTO); try { db.ITEMs.Add(item); db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
public int Adicionar(ItemDTO item) { Item novoItem = new Item { UsuarioId = item.UsuarioId, UnidadeCurricularId = item.UnidadeCurricularId, Nivel = item.Nivel, Gabarito = item.Gabarito, Aprovado = item.Aprovado, Ativo = item.Ativo, }; db.Item.Add(novoItem); db.SaveChanges(); return(novoItem.Id); }
public ItemDTO CreateItem(ItemDTO item) { using (SqlConnection conn = new SqlConnection(connectionString)) using (SqlCommand comm = conn.CreateCommand()) { comm.CommandText = "insert into Item (ItemName, ItemPrice, ItemQuantity, CategoryId) output INSERTED.ItemId values(@name, @price, @qa, @category)"; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@namer", item.ItemName); comm.Parameters.AddWithValue("@price", item.ItemPrice); comm.Parameters.AddWithValue("@qa", item.ItemQuantity); comm.Parameters.AddWithValue("@category", item.Category_Id); conn.Open(); item.ItemId = Convert.ToInt32(comm.ExecuteScalar()); return(item); } }
public void AddItemTest() { ItemDAL dal = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString); Item result = new Item(dal); var item = new ItemDTO { Name = "BL Test", Price = 100, OnStock = 2 }; var r = result.AddItem(item); Assert.IsTrue(r.ItemID != 0, "returned ID should be more than zero"); }
/// <summary> /// Linkses the update. /// </summary> public void LinksUpdate() { linkGW2tp.Links.Clear(); linkWiki.Links.Clear(); if (ViewModel.SelectedControl != null) { ItemDTO item = ViewModel.SelectedControl.ItemDto; if (item != null) { linkGW2tp.Text = "GW2TP: " + item.Name; linkGW2tp.Links.Add(0, 0, String.Format("https://www.gw2tp.com/item/{0}-{1}", item.Id, item.Name.Replace(" ", "-"))); linkWiki.Text = "Wiki: " + item.Name; linkWiki.Links.Add(0, 0, "https://wiki.guildwars2.com/wiki/" + item.Name.Replace(" ", "_")); } } }
private void CheckPurchaseOrderItem(List <PurchaseOrderDDTO> dtoDs) { ErrorItem errorItem; //check item is exists in master ItemBIZ bizItem = new ItemBIZ(); foreach (PurchaseOrderDDTO item in dtoDs) { ItemDTO dtoItem = bizItem.LoadItem(item.ITEM_CD); if (dtoItem == null) { errorItem = new ErrorItem(null, TKPMessages.eValidate.VLM0109.ToString()); throw new BusinessException(errorItem); } } }
public void AtualizarItem() { var facade = new LojaStoneFacade(mockRepositorioCliente.Object, mockRepositorioItem.Object, mockRepositorioPedido.Object, mockServicoMensageria.Object, mockLogger.Object); var itemDTO = new ItemDTO() { Id = 1, Descricao = "Item Teste Mockado 1", Valor = 1.99M }; var retorno1 = facade.AtualizarItemAsync(itemDTO); retorno1.Wait(); mockRepositorioItem.Verify(a => a.AtualizarItemAsync(It.IsAny <Item>()), Times.Once); }
public async Task <IActionResult> GetById(int id) { var shoppingListSpec = new ShoppingListByIdWithItemsSpec(id); var shoppingList = await _repository.GetBySpecAsync(shoppingListSpec); var result = new ShoppingListDTO { Id = shoppingList.Id, Name = shoppingList.Name, Items = new List <ItemDTO> ( shoppingList.Items.Select(i => ItemDTO.FromToDoItem(i)).ToList() ) }; return(Ok(result)); }
public void GivenNewItemWithNameDescriptionPriceAndStockAmountAsAdministrator_WhenCreatingNewItem_ThenReturnStatusCode201WithItemDTO() { //Given ItemDTO itemDto1 = new ItemDTO() { Name = "testItem", Description = "test description", AmountInStock = 5, Price = 10 }; _itemServiceStub.CreateNewItem(itemDto1).Returns(itemDto1); //When CreatedResult result = (CreatedResult)_itemsController.CreateNewItem(itemDto1).Result; //Then Assert.Equal(201, result.StatusCode); Assert.Equal(itemDto1, result.Value); }
private void LoadItemDesc(int iRow) { try { #region validateion List <string> strItemCDList = new List <string>(); for (int i = 0; i < shtView.Rows.Count; i++) { if (i != iRow) { strItemCDList.Add(Convert.ToString(shtView.Cells[i, (int)eColumn.ITEM_CD].Value)); } } ErrorItem errItem = PurchaseOrderEntryValidation.CheckDupItem (new NZString(null, shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_CD].Value), strItemCDList); if (errItem != null) { shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_CD].Value = string.Empty; shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_DESC].Value = string.Empty; ValidateException.ThrowErrorItem(errItem); } #endregion ItemBIZ bizItem = new ItemBIZ(); ItemDTO dtoItem = bizItem.LoadItem((NZString)Convert.ToString(shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_CD].Value)); if (dtoItem != null) { shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_DESC].Value = Convert.ToString(dtoItem.ITEM_DESC); } else { shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_DESC].Value = string.Empty; } } catch (BusinessException err) { MessageDialog.ShowBusiness(this, err.Error.Message); err.Error.FocusOnControl(); } catch (ValidateException err) { MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message); err.ErrorResults[0].FocusOnControl(); } }
public void PostNewItem(ItemDTO item, string username, int warehouseId) { if(item.Id == 0) { // NEW ITEM Item newItem = new Item { Name = item.Name, ImageUrl = item.ImageUrl }; _itemRepo.Add(newItem); _itemRepo.SaveChanges(); WarehouseItem wi = new WarehouseItem { ItemId = newItem.Id, WarehouseId = warehouseId, Quantity = item.WarehouseQty }; _warehouseItemRepo.Add(wi); _warehouseItemRepo.SaveChanges(); } }
partial void Merge(Miniature entity, ItemDTO dto, object state) { entity.MiniatureId = dto.Details.MiniPetId; }
public ItemDTO getItemFromNutratechDb(String item_cd,String SelectedItemDescs, String item_type_cd, String item_class_cd, String item_category_cd) { List<ItemDTO> items = new List<ItemDTO>(); System.Diagnostics.Debug.WriteLine("the item_cd : " + item_cd); System.Diagnostics.Debug.WriteLine("the item_type_cd : " + item_type_cd); System.Diagnostics.Debug.WriteLine("the item_class_cd : " + item_class_cd); System.Diagnostics.Debug.WriteLine("the item_category_cd : " + item_category_cd); String sql = @"SELECT [item_cd] ,[descs], [item_type_cd],[item_category_cd],[item_class_cd] FROM [Nutratech_DB].[dbo].[item] WHERE item_cd =@item_cd AND item_type_cd = @item_type_cd AND item_category_cd = @item_category_cd AND item_class_cd =@item_class_cd;"; ItemDTO item = null; SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.AddWithValue("item_cd", item_cd); cmd.Parameters.AddWithValue("item_type_cd", item_type_cd); cmd.Parameters.AddWithValue("item_category_cd", item_category_cd); cmd.Parameters.AddWithValue("item_class_cd", item_class_cd); SqlDataReader dtr; cn.Open(); dtr = cmd.ExecuteReader(); if (dtr.Read()) { item = new ItemDTO { item_cd = dtr["item_cd"].ToString().Trim(), descs = dtr["descs"].ToString().Trim(), item_type_cd = dtr["item_type_cd"].ToString().Trim(), item_category_cd = dtr["item_category_cd"].ToString().Trim(), item_class_cd = dtr["item_class_cd"].ToString().Trim() }; } //while (dtr.Read()) //{ //} cn.Close(); cn.Dispose(); JavaScriptSerializer ser = new JavaScriptSerializer(); System.Diagnostics.Debug.WriteLine("the item is : " + ser.Serialize(item)); return item ; }
public static ItemDTO CreateItemDTO(int ID, bool isLife) { ItemDTO itemDTO = new ItemDTO(); itemDTO.Id = ID; itemDTO.IsLife = isLife; return itemDTO; }
public void AddToItems(ItemDTO itemDTO) { base.AddObject("Items", itemDTO); }