示例#1
0
        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);
                }
        }
示例#2
0
        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
            });
        }
示例#3
0
        public async Task CreateGoodsAsync(GoodsDTO goodsDTO)
        {
            var searchedGoods = await _unitOfWork.GoodsRepository
                                .GetByIdAsync(goodsDTO.Id);

            await _unitOfWork.GoodsRepository.UpdateAsync(searchedGoods);
        }
示例#4
0
        public async Task ChangeDesriptionAsync(GoodsDTO goodsDTO, string description)
        {
            var searchedGoods = await _unitOfWork.GoodsRepository
                                .GetByIdAsync(goodsDTO.Id);

            await _unitOfWork.GoodsRepository.UpdateAsync(searchedGoods);
        }
示例#5
0
        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);
        }
示例#6
0
        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();
        }
示例#7
0
        public async Task <ActionResult> GetModel(long id)
        {
            GoodsDTO res = await goodsService.GetModelAsync(id);

            return(Json(new AjaxResult {
                Status = 1, Data = res
            }));
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#10
0
 public void UpdateGoods(GoodsDTO goods)
 {
     try
     {
         GoodsDAO.Instance.UpdateGoods(goods);
     }
     catch (MySqlException ex)
     {
         throw new BUSException(ex.Message);
     }
 }
示例#11
0
        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);
        }
示例#12
0
 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);
     }
 }
示例#13
0
        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));
        }
示例#14
0
        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));
        }
示例#15
0
        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
            {
            }
        }
示例#17
0
 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);
     }
 }
示例#18
0
        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);
                }
        }
示例#19
0
        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();
        }
示例#20
0
        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);
        }
示例#21
0
        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);
        }
示例#22
0
        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
            {
            }
        }
示例#24
0
 public void Post([FromBody] GoodsDTO model)
 {
     _goodsAppService.AddGoods(model, UserId);
 }
示例#25
0
 public async Task <GoodsDTO> GetGoods(int id)
 {
     return(GoodsDTO.From(await _goodsService.Get(id)));
 }
示例#26
0
 public async Task <List <GoodsDTO> > GetAllGoods()
 {
     return(GoodsDTO.From(await _goodsService.GetAll()));
 }
示例#27
0
 public void Put([FromBody] GoodsDTO model)
 {
     _goodsAppService.UpdateGoods(model, UserId);
 }