public GoodsDTO GetGoodsByName(string name) { using (SqlConnection conn = new SqlConnection(this._connectionString)) using (SqlCommand comm = conn.CreateCommand()) { conn.Open(); GoodsDTO goods = new GoodsDTO(); comm.CommandText = $"select * from User where Name={name}"; SqlDataReader reader = comm.ExecuteReader(); while (reader.Read()) { goods = new GoodsDTO { GoodsID = Convert.ToInt32(reader["GoodsID"]), GoodsName = reader["GoodsName"].ToString(), GoodsPrice = reader["GoodsPrice"].ToString(), GoodsDescription = reader["GoodsDescription"].ToString(), GoodsAmount = reader["GoodsAmount"].ToString() }; } return(goods); } }
public async Task <ApiResult> Detail(GoodsDetailModel model) { string parm = await settingService.GetParmByNameAsync("网站域名"); GoodsDTO dto = await goodsService.GetModelAsync(model.Id); GoodsImgSearchResult result = await goodsImgService.GetModelListAsync(dto.Id, null, null, null, 1, 100); GoodsDetailApiModel apiModel = new GoodsDetailApiModel(); apiModel.goodsImgs = result.GoodsImgs.Select(g => new GoodsImg { id = g.Id, imgUrl = parm + g.ImgUrl }).ToList(); if (dto != null) { apiModel.id = dto.Id; apiModel.description = dto.Description.Replace("/upload/", parm + "/upload/"); apiModel.inventory = dto.Inventory; apiModel.name = dto.Name; apiModel.price = dto.Price; apiModel.realityPrice = dto.RealityPrice; apiModel.saleNum = dto.SaleNum; } return(new ApiResult { status = 1, data = apiModel }); }
public async Task CreateGoodsAsync(GoodsDTO goodsDTO) { var searchedGoods = await _unitOfWork.GoodsRepository .GetByIdAsync(goodsDTO.Id); await _unitOfWork.GoodsRepository.UpdateAsync(searchedGoods); }
public async Task ChangeDesriptionAsync(GoodsDTO goodsDTO, string description) { var searchedGoods = await _unitOfWork.GoodsRepository .GetByIdAsync(goodsDTO.Id); await _unitOfWork.GoodsRepository.UpdateAsync(searchedGoods); }
private GoodsDTO ToDTO(GoodsEntity entity) { GoodsDTO dto = new GoodsDTO(); dto.Code = entity.Code; dto.CreateTime = entity.CreateTime; dto.Description = entity.Description; dto.GoodsAreaId = entity.GoodsAreaId; dto.GoodsAreaTitle = ""; dto.GoodsSecondTypeId = entity.GoodsSecondType.Name == "空类型" ? (long?)null : entity.GoodsSecondTypeId; dto.GoodsSecondTypeName = entity.GoodsSecondType.Name == "空类型" ? "" : entity.GoodsSecondType.Name; dto.GoodsTypeId = entity.GoodsTypeId; dto.GoodsTypeName = entity.GoodsType.Name; dto.Id = entity.Id; dto.Inventory = entity.Inventory; dto.IsPutaway = entity.IsPutaway; dto.IsRecommend = entity.IsRecommend; dto.Name = entity.Name; dto.Price = entity.Price; dto.RealityPrice = entity.RealityPrice; dto.SaleNum = entity.SaleNum; dto.Standard = entity.Standard; dto.IsHotSale = entity.IsHotSale; return(dto); }
public void UpdateGoods(GoodsDTO goodsDTO, string operatorId) { var goods = _goodsRepository.Get(goodsDTO.Id); if (goods == null) { return; } goods.ItemNumber = goodsDTO.ItemNumber; goods.Category = goodsDTO.Category; goods.SubCategory = goodsDTO.SubCategory; goods.Title = goodsDTO.Title; goods.Description = goodsDTO.Description; goods.Detail = goodsDTO.Detail; goods.UnitPrice = goodsDTO.UnitPrice; goods.MarketPrice = goodsDTO.MarketPrice; goods.Unit = goodsDTO.Unit; goods.Stock = goodsDTO.Stock; goods.StoreId = goodsDTO.StoreId; goods.LastUpdBy = operatorId; goods.LastUpdOn = DateTime.Now; goods.OptionalPropertyJsonObject = goodsDTO.OptionalPropertyJsonObject; goods.Address = goodsDTO.Address; goods.DistributionScope = goodsDTO.DistributionScope; goods.VideoPath = goodsDTO.VideoPath; goods.GoodsCategoryName = goodsDTO.GoodsCategoryName; goods.InitAddress(); goods.InitStatus(); var imgs = _goodsImageRepository.GetFiltered(o => o.GoodsId == goods.Id).ToList(); imgs.ForEach(img => { _goodsImageRepository.Remove(img); }); var conditions = _grouponConditionRepository.GetFiltered(o => o.GoodsId == goods.Id).ToList(); conditions.ForEach(condition => { _grouponConditionRepository.Remove(condition); }); if (goodsDTO.GoodsImages != null && goodsDTO.GoodsImages.Count() > 0) { foreach (var item in goodsDTO.GoodsImages) { _goodsImageRepository.Add(new GoodsImage { CreatedOn = DateTime.Now, GoodsId = goodsDTO.Id, ImageId = item.ImageId }); } } if (goodsDTO.GrouponConditions != null && goodsDTO.GrouponConditions.Count() > 0) { foreach (var item in goodsDTO.GrouponConditions) { _grouponConditionRepository.Add(new GrouponCondition { GoodsId = goodsDTO.Id, MoreThanNumber = item.MoreThanNumber, Price = item.Price }); } } _dbUnitOfWork.Commit(); }
public async Task <ActionResult> GetModel(long id) { GoodsDTO res = await goodsService.GetModelAsync(id); return(Json(new AjaxResult { Status = 1, Data = res })); }
public void DeleteGoods(int id) { Console.WriteLine("Enter ID to delete:"); GoodsDTO goods = new GoodsDTO(); goods.GoodsID = Convert.ToInt32(Console.ReadLine()); Console.WriteLine($"Deleting user ID: {goods.GoodsID}"); _goodsDAL.DeleteGoods(goods.GoodsID); }
public async Task DeleteAsync( [NotNull] GoodsDTO entity, CancellationToken token = default(CancellationToken)) { Guard.NotNull(entity, nameof(entity)); _context.Goods.Remove(entity); await _context.SaveChangesAsync(token).ConfigureAwait(false); }
public void UpdateGoods(GoodsDTO goods) { try { GoodsDAO.Instance.UpdateGoods(goods); } catch (MySqlException ex) { throw new BUSException(ex.Message); } }
public async Task AssignRoomAsync(RoomDTO roomDTO, GoodsDTO goodsDTO) { var searchedRoom = await _unitOfWork.RoomRepository .GetByIdAsync(roomDTO.Id); var searchedGoods = await _unitOfWork.GoodsRepository .GetByIdAsync(goodsDTO.Id); await _unitOfWork.RoomRepository.UpdateAsync(searchedRoom); await _unitOfWork.GoodsRepository.UpdateAsync(searchedGoods); }
public bool Update(GoodsDTO dto) { using (MyDbContext dbc = new MyDbContext()) { CommonService <GoodsEntity> cs = new CommonService <GoodsEntity>(dbc); var goods = cs.GetAll().SingleOrDefault(g => g.ID == dto.ID); if (goods == null) { return(false); } goods.AddTime = dto.AddTime; goods.CreateTime = dto.CreateTime; goods.FLH1 = dto.FLH1; goods.FLH2 = dto.FLH2; goods.FLH3 = dto.FLH3; goods.FLJ1 = dto.FLJ1; goods.FLJ2 = dto.FLJ2; goods.FLJ3 = dto.FLJ3; goods.FLT1 = dto.FLT1; goods.FLT2 = dto.FLT2; goods.FLT3 = dto.FLT3; goods.Goods001 = dto.Goods001; goods.Goods002 = dto.Goods002; goods.Goods003 = dto.Goods003; goods.Goods004 = dto.Goods004; goods.Goods005 = dto.Goods005; goods.Goods006 = dto.Goods006; goods.Goods007 = dto.Goods007; goods.Goods008 = dto.Goods008; goods.GoodsCode = dto.GoodsCode; goods.GoodsName = dto.GoodsName; goods.GoodsName_en = dto.GoodsName_en; goods.GoodsType = dto.GoodsType; goods.IsHave = dto.IsHave; goods.Pic1 = dto.Pic1; goods.Pic2 = dto.Pic2; goods.Pic3 = dto.Pic3; goods.Pic4 = dto.Pic4; goods.Pic5 = dto.Pic5; goods.Price = dto.Price; goods.RealityPrice = dto.RealityPrice; goods.Remarks = dto.Remarks; goods.Remarks_en = dto.Remarks_en; goods.Standard = dto.Standard; goods.Summary = dto.Summary; goods.TypeID = dto.TypeID; dbc.Goods.Add(goods); dbc.SaveChanges(); return(true); } }
public GoodsDTO UpdateGoods(GoodsDTO goods) { Console.WriteLine("Change goods inf0: \n"); Console.WriteLine("Full name,Mail"); goods = new GoodsDTO { GoodsName = Console.ReadLine(), GoodsPrice = Console.ReadLine(), GoodsDescription = Console.ReadLine() }; return(_goodsDAL.UpdateGoods(goods)); }
public GoodsDTO CreateGoods(GoodsDTO goods) { Console.WriteLine("GoodsName, GoodsPrice, GoodsDescription, GoodsAmount"); goods = new GoodsDTO { GoodsName = Console.ReadLine(), GoodsPrice = Console.ReadLine(), GoodsDescription = Console.ReadLine(), GoodsAmount = Console.ReadLine() }; return(_goodsDAL.CreateGoods(goods)); }
public async Task <GoodsDTO> UpdateAsync( [NotNull] GoodsDTO entity, CancellationToken token = default(CancellationToken)) { if (!await ExistsByIdAsync(entity.Id, token).ConfigureAwait(false)) { return(null); } _context.Goods.Update(entity); await _context.SaveChangesAsync(token).ConfigureAwait(false); return(entity); }
public MySqlDataReader UpdateGoods(GoodsDTO goods) { try { //ExcuteQuery MySqlDataReader reader = MySqlConnectionDAO.Instance.ExcuteProcedure("UpdateGoods", new MySqlParameter("@_ID", goods.ID), new MySqlParameter("@_Name", goods.Name), new MySqlParameter("@_SupplierID", goods.SupplierID), new MySqlParameter("@_UnitPrice", goods.UnitPrice)); return(reader); } finally { } }
public long Add(GoodsDTO dto) { using (MyDbContext dbc = new MyDbContext()) { GoodsEntity goods = new GoodsEntity(); goods.AddTime = dto.AddTime; goods.CreateTime = dto.CreateTime; goods.FLH1 = dto.FLH1; goods.FLH2 = dto.FLH2; goods.FLH3 = dto.FLH3; goods.FLJ1 = dto.FLJ1; goods.FLJ2 = dto.FLJ2; goods.FLJ3 = dto.FLJ3; goods.FLT1 = dto.FLT1; goods.FLT2 = dto.FLT2; goods.FLT3 = dto.FLT3; goods.Goods001 = dto.Goods001; goods.Goods002 = dto.Goods002; goods.Goods003 = dto.Goods003; goods.Goods004 = dto.Goods004; goods.Goods005 = dto.Goods005; goods.Goods006 = dto.Goods006; goods.Goods007 = dto.Goods007; goods.Goods008 = dto.Goods008; goods.GoodsCode = dto.GoodsCode; goods.GoodsName = dto.GoodsName; goods.GoodsName_en = dto.GoodsName_en; goods.GoodsType = dto.GoodsType; goods.IsHave = dto.IsHave; goods.Pic1 = dto.Pic1; goods.Pic2 = dto.Pic2; goods.Pic3 = dto.Pic3; goods.Pic4 = dto.Pic4; goods.Pic5 = dto.Pic5; goods.Price = dto.Price; goods.RealityPrice = dto.RealityPrice; goods.Remarks = dto.Remarks; goods.Remarks_en = dto.Remarks_en; goods.Standard = dto.Standard; goods.Summary = dto.Summary; goods.TypeID = dto.TypeID; dbc.Goods.Add(goods); dbc.SaveChanges(); return(goods.ID); } }
public GoodsDTO CreateGoods(GoodsDTO goods) { using (SqlConnection conn = new SqlConnection(this._connectionString)) using (SqlCommand comm = conn.CreateCommand()) { comm.CommandText = "insert into User (Name, Price, Description, Amount) values (@GoodsName, @GoodsPrice, @GoodsDescription, @GoodsAmount)"; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@GoodsName", goods.GoodsName); comm.Parameters.AddWithValue("@GoodsPrice", goods.GoodsPrice); comm.Parameters.AddWithValue("@GoodsDescription", goods.GoodsDescription); comm.Parameters.AddWithValue("@GoodsAmount", goods.GoodsAmount); conn.Open(); goods.GoodsID = Convert.ToInt32(comm.ExecuteScalar()); return(goods); } }
public void AddGoods(GoodsDTO goodsDTO, string creatorId) { var goodsImages = goodsDTO.GoodsImages.Select(item => new GoodsImage { CreatedOn = DateTime.Now, ImageId = item.ImageId }).ToList(); var grouponConditions = goodsDTO.GrouponConditions.Select(item => new GrouponCondition { MoreThanNumber = item.MoreThanNumber, Price = item.Price }).ToList(); var obj = GoodsFactory.CreateGoods( goodsDTO.ItemNumber, goodsDTO.Category, goodsDTO.SubCategory, goodsDTO.Title, goodsDTO.Description, goodsDTO.Detail, goodsDTO.UnitPrice, goodsDTO.MarketPrice, goodsDTO.Unit, goodsDTO.Stock, goodsDTO.StoreId, creatorId, goodsDTO.OptionalPropertyJsonObject, grouponConditions, goodsImages, goodsDTO.Address, goodsDTO.DistributionScope, goodsDTO.GoodsCategoryName, goodsDTO.VideoPath); _goodsRepository.Add(obj); goodsImages.ForEach(item => { _goodsImageRepository.Add(item); }); grouponConditions.ForEach(item => { _grouponConditionRepository.Add(item); }); _dbUnitOfWork.Commit(); }
public List <GoodsDTO> GetGoods() { List <GoodsDTO> goods = new List <GoodsDTO>(); foreach (var g in context.Goods.ToList()) { GoodsDTO good = new GoodsDTO() { Goods = g.Goods1, Unit = g.Unit, Quantity = g.Quantity, Description = g.Description }; goods.Add(good); } return(goods); }
public GoodsDTO ToDTO(GoodsEntity goods) { GoodsDTO dto = new GoodsDTO(); dto.AddTime = goods.AddTime; dto.CreateTime = goods.CreateTime; dto.FLH1 = goods.FLH1; dto.FLH2 = goods.FLH2; dto.FLH3 = goods.FLH3; dto.FLJ1 = goods.FLJ1; dto.FLJ2 = goods.FLJ2; dto.FLJ3 = goods.FLJ3; dto.FLT1 = goods.FLT1; dto.FLT2 = goods.FLT2; dto.FLT3 = goods.FLT3; dto.Goods001 = goods.Goods001; dto.Goods002 = goods.Goods002; dto.Goods003 = goods.Goods003; dto.Goods004 = goods.Goods004; dto.Goods005 = goods.Goods005; dto.Goods006 = goods.Goods006; dto.Goods007 = goods.Goods007; dto.Goods008 = goods.Goods008; dto.GoodsCode = goods.GoodsCode; dto.GoodsName = goods.GoodsName; dto.GoodsName_en = goods.GoodsName_en; dto.GoodsType = goods.GoodsType; dto.IsHave = goods.IsHave; dto.Pic1 = goods.Pic1; dto.Pic2 = goods.Pic2; dto.Pic3 = goods.Pic3; dto.Pic4 = goods.Pic4; dto.Pic5 = goods.Pic5; dto.Price = goods.Price; dto.RealityPrice = goods.RealityPrice; dto.Remarks = goods.Remarks; dto.Remarks_en = goods.Remarks_en; dto.Standard = goods.Standard; dto.Summary = goods.Summary; dto.TypeID = goods.TypeID; dto.ID = goods.ID; return(dto); }
public GoodsDTO UpdateGoods(GoodsDTO goods) { using (SqlConnection conn = new SqlConnection(this._connectionString)) using (SqlCommand comm = conn.CreateCommand()) { comm.CommandText = "update Goods set GoodsName= @GoodsName,GoodsPrice = @GoodsPrice, GoodsDescription=@GoodsDescription, GoodsAmount=@GoodsAmount where ID = @ID"; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@GoodsID", goods.GoodsID); comm.Parameters.AddWithValue("@GoodsName", goods.GoodsName); comm.Parameters.AddWithValue("@GoodsPrice", goods.GoodsPrice); comm.Parameters.AddWithValue("@GoodsDescription", goods.GoodsDescription); comm.Parameters.AddWithValue("@GoodsAmount", goods.GoodsAmount); conn.Open(); goods.GoodsID = Convert.ToInt32(comm.ExecuteScalar()); return(goods); } }
public GoodsDTO FindGoodsByID(string goodsID, bool status = true) { try { //A variable to store goods's information GoodsDTO goods = null; MySqlDataReader reader = MySqlConnectionDAO.Instance.ExcuteProcedure("FindGoods", new MySqlParameter("@_ID", goodsID), new MySqlParameter("@_Status", status)); //get goods's information while (reader.Read()) { goods = new GoodsDTO(reader.GetString("ID"), reader.GetString("GoodsName"), reader.GetString("SupplierID"), decimal.Parse(reader.GetString("UnitPrice")), int.Parse(reader.GetString("Stock"))); } return(goods); } finally { } }
public void Post([FromBody] GoodsDTO model) { _goodsAppService.AddGoods(model, UserId); }
public async Task <GoodsDTO> GetGoods(int id) { return(GoodsDTO.From(await _goodsService.Get(id))); }
public async Task <List <GoodsDTO> > GetAllGoods() { return(GoodsDTO.From(await _goodsService.GetAll())); }
public void Put([FromBody] GoodsDTO model) { _goodsAppService.UpdateGoods(model, UserId); }