Example #1
0
        public GoodDto UpdateGood(GoodDto goodDto)
        {
            Execute($"UPDATE [dbo].[Good] SET [Price] = @Price, [Count] = @Count WHERE [BookId] = @BookId", goodDto);
            var result = GetGoodByBookId(goodDto.BookId);

            return(result);
        }
Example #2
0
 /// <summary>
 /// Создать товар
 /// </summary>
 /// <param name="good">Товар</param>
 /// <param name="sessionRows">Кол-во товара в рамках сессии</param>
 /// <param name="goodsTotal">Кол-во товаров в системе</param>
 private void CreateGood(GoodDto good, int sessionRows, int goodsTotal)
 {
     for (int i = 0; i < (sessionRows - goodsTotal); i++)
     {
         _context.Add(_mapper.Mapper.Map <GoodDto, Good>(good));
     }
 }
Example #3
0
        public Book Update(Book book)
        {
            var bookDto = new BookDto()
            {
                Id          = book.Id,
                Name        = book.Name,
                Description = book.Description,
                ReleaseDate = book.ReleaseDate,
                Image       = book.Image
            };

            var goodDto = new GoodDto()
            {
                BookId = book.Id,
                Count  = book.Count,
                Price  = book.Price
            };

            _goodRepository.UpdateGood(goodDto);
            var bookResult = _bookRepository.Update(bookDto);

            _authorRepository.DeleteBookAuthorByBookId(book.Id);
            _genreRepository.DeleteBookGenreByBookId(book.Id);

            book.AuthorIds.ForEach(authorId =>
            {
                _authorRepository.AddBookAuthor(new BookAuthorDto()
                {
                    BookId   = bookResult.Id,
                    AuthorId = authorId
                });
            });

            book.GenreIds.ForEach(genreId =>
            {
                _genreRepository.AddBookGenre(new BookGenreDto()
                {
                    BookId  = bookResult.Id,
                    GenreId = genreId
                });
            });

            return(new Book()
            {
                Id = bookResult.Id,
                Name = bookResult.Name,
                Description = bookResult.Description,
                ReleaseDate = bookResult.ReleaseDate,
                Count = bookResult.Count,
                Price = bookResult.Price,
                Image = bookResult.Image,
                AuthorIds = book.AuthorIds,
                GenreIds = book.GenreIds
            });
        }
Example #4
0
        public void UpdateGood(GoodDto good)
        {
            var dbGood = _goodsRepository.GetByUniqueNumber(good.ItemUniqueId);

            dbGood.Name                 = good.Name;
            dbGood.Amount               = good.Amount;
            dbGood.CategoryId           = good.CategoryId;
            dbGood.Price                = good.Price;
            dbGood.ShortCharacteristics = good.ShortCharacteristics;
            dbGood.Characteristics      = good.Characteristics;

            this._goodsRepository.Update(dbGood);
            this._goodsRepository.SaveChanges();;
        }
        public async Task <IActionResult> GetGood(string key, string field)
        {
            //var currentUserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            Good good;

            if (field.Equals("name"))
            {
                good = await _repo.GetFirstAsync(woak => woak.FarshboomCode.Equals(key));
            }
            else
            {
                good = await _repo.GetFirstAsync(woak => woak.Id == Convert.ToInt32(key));
            }
            GoodDto goodDto = _mapper.Map <GoodDto>(good);

            return(Ok(new { goodDto = goodDto }));
        }
Example #6
0
        public void AddGood(GoodDto good)
        {
            var dbGood = new Good()
            {
                Name                 = good.Name,
                Amount               = good.Amount,
                CategoryId           = good.CategoryId,
                Price                = good.Price,
                ShortCharacteristics = good.ShortCharacteristics,
                Characteristics      = good.Characteristics,
                ItemUniqueId         = ""
            };

            this._goodsRepository.Add(dbGood);
            this._goodsRepository.SaveChanges();

            dbGood.ItemUniqueId = $"{dbGood.CategoryId}{dbGood.Name.Substring(0, 2)}{dbGood.Id}";
            this._goodsRepository.SaveChanges();
        }
 public Good MapToEntity(GoodDto model)
 {
     //            var Units = new Collection<GoodUnit>();
     //            model.Units.ForEach(p =>
     //                                    {
     //                                        var u = new UnitX(p.Id,p.Name);
     //                                        Units.Add(u);
     //                                    });
     ////
     ////            model.Brands.ForEach(p =>
     ////                                    {
     ////                                        var b = new Brand(p.Id,p.Name);
     ////                                        Brands.Add(b);
     ////                                    });
     //            var res = new Good(model.Id, model.Name, model.Code,Units);
     //
     //            return res;
     return null;
 }
Example #8
0
        public async Task CreateDish(GoodDto goodDto, Guid categoryId, CancellationToken cancellationToken)
        {
            var createCommand = new CreateDishCommand(
                goodDto.Id,
                categoryId,
                goodDto.Description,
                goodDto.Measure,
                isAvailable: true,
                goodDto.Name,
                goodDto.Price);

            var content =
                new StringContent(JsonSerializer.Serialize(createCommand), Encoding.UTF8, "application/json");

            using var response = await this.httpClient.PostAsync(this.options.DishesUri, content, cancellationToken)
                                 .ConfigureAwait(false);

            if (response.StatusCode != HttpStatusCode.Conflict)
            {
                response.EnsureSuccessStatusCode();
            }
        }
Example #9
0
        public async Task PatchDish(Guid id, GoodDto groupDto, Guid categoryId, CancellationToken cancellationToken)
        {
            var command = new
            {
                Id          = id,
                CategoryId  = categoryId,
                Consist     = groupDto.Description,
                Unit        = groupDto.Measure,
                IsAvailable = true,
                Name        = groupDto.Name,
                Price       = groupDto.Price
            };

            var content =
                new StringContent(JsonSerializer.Serialize(command), Encoding.UTF8, "application/json");

            using var response = await this.httpClient.PatchAsync(this.options.DishesUri, content, cancellationToken)
                                 .ConfigureAwait(false);

            if (response.StatusCode != HttpStatusCode.Conflict)
            {
                response.EnsureSuccessStatusCode();
            }
        }
Example #10
0
 public void UpdateGood(GoodDto good)
 {
     this._goodService.UpdateGood(good);
 }
Example #11
0
 public void AddGood(GoodDto good)
 {
     this._goodService.AddGood(good);
 }
 public GoodDto RemapModel(GoodDto model)
 {
     throw new NotImplementedException();
 }
Example #13
0
        public IActionResult GetGood(string key, string field)
        {
            string        connectionString = "Data Source=185.88.152.127,1430;Initial Catalog=94_farsheboom ;User Id=94_vaq;Password=V@qef2512740;MultipleActiveResultSets=True;Max Pool Size=9000;persist security info=True;";
            SqlConnection cnn = new SqlConnection(connectionString);

            if (cnn.State == ConnectionState.Closed)
            {
                cnn.Open();
            }
            SqlCommand command = new SqlCommand();

            command.Connection = cnn;
            //
            command.CommandText = @"SELECT [srl], [porz_type] ,[chele_type] ,[carpet_type] ,[ibt_srl] ,[size_srl] ,[color_srl] ,[color_srl2], [raj_srl], [title_igd], [lenght] ,[widht] ,[code_igd] ,[provider_code] ,[brand_name], [size_title], [color_name], [porz_title], [carpet_title] FROM [94_farsheboom].[94_vaq].[FarshBoomSite] Where (sold = 0 or sold is null) And srl=" + key;
            SqlDataReader reader = command.ExecuteReader();

            GoodDto good = new GoodDto();

            while (reader.Read())
            {
                if (reader["title_igd"].ToString().Length < 5)
                {
                    continue;
                }

                good.Id            = Convert.ToInt32(reader["srl"]);
                good.ImageUrl      = reader["title_igd"].ToString();
                good.FarshboomCode = reader["code_igd"].ToString();
                good.ProviderCode  = reader["provider_code"].ToString();

                good.Brand = reader["brand_name"].ToString();
                good.Size  = reader["size_title"].ToString();
                good.Color = reader["color_name"].ToString();
                good.Porz  = reader["porz_title"].ToString();
                good.Type  = reader["carpet_title"].ToString();

                good.ImageUrl = reader["title_igd"].ToString();
                good.ImageUrl = good.ImageUrl.Replace("../", "http://bank.farshboom.com/");
                if (reader["porz_type"] != null && !Convert.IsDBNull(reader["porz_type"]))
                {
                    good.PorzId = Convert.ToInt32(reader["porz_type"]);
                }
                if (reader["chele_type"] != null && !Convert.IsDBNull(reader["chele_type"]))
                {
                    good.CheleId = Convert.ToInt32(reader["chele_type"]);
                }
                if (reader["carpet_type"] != null && !Convert.IsDBNull(reader["carpet_type"]))
                {
                    good.TypeId = Convert.ToInt32(reader["carpet_type"]);
                }
                if (reader["ibt_srl"] != null && !Convert.IsDBNull(reader["ibt_srl"]))
                {
                    good.BrandId = Convert.ToInt32(reader["ibt_srl"]);
                }
                if (reader["size_srl"] != null && !Convert.IsDBNull(reader["size_srl"]))
                {
                    good.SizeId = Convert.ToInt32(reader["size_srl"]);
                }
                if (reader["color_srl"] != null && !Convert.IsDBNull(reader["color_srl"]))
                {
                    good.ColorId = Convert.ToInt32(reader["color_srl"]);
                }
                if (reader["color_srl2"] != null && !Convert.IsDBNull(reader["color_srl2"]))
                {
                    good.ColorId2 = Convert.ToInt32(reader["color_srl2"]);
                }
                if (reader["lenght"] != null && !Convert.IsDBNull(reader["lenght"]))
                {
                    good.Lenght = Convert.ToInt32(reader["lenght"]);
                }
                if (reader["widht"] != null && !Convert.IsDBNull(reader["widht"]))
                {
                    good.Width = Convert.ToInt32(reader["widht"]);
                }
                if (reader["raj_srl"] != null && !Convert.IsDBNull(reader["raj_srl"]))
                {
                    good.RajId = Convert.ToInt32(reader["raj_srl"]);
                }
            }
            cnn.Close();
            return(Ok(new { goodDto = good }));
        }
Example #14
0
        public IActionResult GetAllGoods([FromQuery] UserParams userParams)
        {
            string where = string.Empty;
            if (userParams.TypeId != null)
            {
                where += "And carpet_type = " + userParams.TypeId;
            }
            if (userParams.SizeId != null)
            {
                where += "And size_srl = " + userParams.SizeId;
            }
            if (userParams.BrandId != null)
            {
                where += "And ibt_srl = " + userParams.BrandId;
            }
            if (userParams.ColorId != null)
            {
                where += "And color_srl = " + userParams.ColorId;
            }
            if (userParams.PorzId != null)
            {
                where += "And porz_type = " + userParams.PorzId;
            }
            if (userParams.Length != null)
            {
                where += "And lenght = " + userParams.Length;
            }
            if (userParams.Weight != null)
            {
                where += "And widht = " + userParams.Weight;
            }

            if (userParams.CheleId != null)
            {
                where += "And chele_type = " + userParams.CheleId;
            }
            if (userParams.PlanId != null)
            {
                where += "And city_srl = " + userParams.PlanId;
            }
            if (userParams.AssessmentId != null)
            {
                where += "And carpet_type = " + userParams.AssessmentId;
            }
            if (userParams.FromPrice != null && userParams.ToPrice != null)
            {
                where += "And sale_price BETWEEN " + userParams.FromPrice + " And " + userParams.ToPrice;
            }


            string        connectionString = "Data Source=185.88.152.127,1430;Initial Catalog=94_farsheboom ;User Id=94_vaq;Password=V@qef2512740;MultipleActiveResultSets=True;Max Pool Size=9000;persist security info=True;";
            SqlConnection cnn = new SqlConnection(connectionString);

            if (cnn.State == ConnectionState.Closed)
            {
                cnn.Open();
            }
            SqlCommand command = new SqlCommand();

            command.Connection = cnn;
            //
            command.CommandText = @"SELECT Top(300) [srl], [porz_type] ,[chele_type] ,[carpet_type] ,[ibt_srl] ,[size_srl] ,[color_srl] ,[color_srl2], [raj_srl], [title_igd], [lenght] ,[widht] ,[code_igd] ,[provider_code] ,[brand_name], [size_title], [color_name], [porz_title], [carpet_title], [city_srl], [sale_price], [raj_title] FROM [94_farsheboom].[94_vaq].[FarshBoomSite] Where (sold = 0 or sold is null)" + where + " Order By srl Desc";
            SqlDataReader  reader  = command.ExecuteReader();
            List <GoodDto> lstGood = new List <GoodDto>();

            while (reader.Read())
            {
                if (reader["title_igd"].ToString().Length < 5)
                {
                    continue;
                }
                GoodDto good = new GoodDto();
                good.Id            = Convert.ToInt32(reader["srl"]);
                good.ImageUrl      = reader["title_igd"].ToString();
                good.FarshboomCode = reader["code_igd"].ToString();
                good.ProviderCode  = reader["provider_code"].ToString();

                good.Brand = reader["brand_name"].ToString();
                good.Size  = reader["size_title"].ToString();
                good.Color = reader["color_name"].ToString();
                good.Porz  = reader["porz_title"].ToString();
                good.Type  = reader["carpet_title"].ToString();

                good.Chele = reader["chele_title"].ToString();
                good.Plan  = reader["plan_title"].ToString();
                good.Raj   = reader["raj_title"].ToString();

                good.ImageUrl = reader["title_igd"].ToString();
                good.ImageUrl = good.ImageUrl.Replace("../", "http://bank.farshboom.com/");
                if (reader["porz_type"] != null && !Convert.IsDBNull(reader["porz_type"]))
                {
                    good.PorzId = Convert.ToInt32(reader["porz_type"]);
                }
                if (reader["chele_type"] != null && !Convert.IsDBNull(reader["chele_type"]))
                {
                    good.CheleId = Convert.ToInt32(reader["chele_type"]);
                }
                if (reader["carpet_type"] != null && !Convert.IsDBNull(reader["carpet_type"]))
                {
                    good.TypeId = Convert.ToInt32(reader["carpet_type"]);
                }
                if (reader["ibt_srl"] != null && !Convert.IsDBNull(reader["ibt_srl"]))
                {
                    good.BrandId = Convert.ToInt32(reader["ibt_srl"]);
                }
                if (reader["size_srl"] != null && !Convert.IsDBNull(reader["size_srl"]))
                {
                    good.SizeId = Convert.ToInt32(reader["size_srl"]);
                }
                if (reader["color_srl"] != null && !Convert.IsDBNull(reader["color_srl"]))
                {
                    good.ColorId = Convert.ToInt32(reader["color_srl"]);
                }
                if (reader["color_srl2"] != null && !Convert.IsDBNull(reader["color_srl2"]))
                {
                    good.ColorId2 = Convert.ToInt32(reader["color_srl2"]);
                }
                if (reader["lenght"] != null && !Convert.IsDBNull(reader["lenght"]))
                {
                    good.Lenght = Convert.ToInt32(reader["lenght"]);
                }
                if (reader["widht"] != null && !Convert.IsDBNull(reader["widht"]))
                {
                    good.Width = Convert.ToInt32(reader["widht"]);
                }
                if (reader["raj_srl"] != null && !Convert.IsDBNull(reader["raj_srl"]))
                {
                    good.RajId = Convert.ToInt32(reader["raj_srl"]);
                }
                if (reader["city_srl"] != null && !Convert.IsDBNull(reader["city_srl"]))
                {
                    good.RajId = Convert.ToInt32(reader["city_srl"]);
                }
                if (reader["sale_price"] != null && !Convert.IsDBNull(reader["sale_price"]))
                {
                    good.SalePrice = Convert.ToInt32(reader["sale_price"]);
                }

                lstGood.Add(good);
            }
            cnn.Close();

            var pagedList = lstGood.AsQueryable();
            var goods     = Paginiation <GoodDto> .CreateAsync(pagedList, userParams.PageNumber, userParams.PageSize);

            IEnumerable <GoodDto> goodDto;

            goodDto = _mapper.Map <IEnumerable <GoodDto> >(goods);


            Response.AddPagination(goods.CurrentPage, goods.PageSize,
                                   goods.TotalCount, goods.TotalPages);
            return(Ok(goodDto));
        }
Example #15
0
 public bool AddGood(GoodDto goodDto)
 {
     Execute($"INSERT INTO [dbo].[Good] ([BookId], [Count], [Price]) VALUES (@BookId, @Count, @Price)", goodDto);
     return(true);
 }