Ejemplo n.º 1
0
        public async Task <IActionResult> CreatWholePrice(string Value, int productId)
        {
            var list    = JsonConvert.DeserializeObject <List <CreatWholePrice> >(Value);
            var request = new CreatWholePriceViewModel()
            {
                ProductId = productId,
                ListCreat = list
            };
            var creat = await _productConnectAPI.CreatWholePrice(request);

            if (creat == true)
            {
                var annount = new AnnouncementViewModel()
                {
                    UserName    = User.Identity.Name,
                    DeCripstion = "Create Successfull Whole Price ",
                    Content     = "Creat Role",
                    DateCreated = DateTime.Now,
                };
                await _hubContext.Clients.All.SendAsync("ReceiveMessage", annount);
            }
            return(Json(new
            {
                status = true,
            }));
        }
Ejemplo n.º 2
0
        public async Task <bool> CreatWholePrice(CreatWholePriceViewModel request)
        {
            var json       = JsonConvert.SerializeObject(request);
            var jsonstring = new StringContent(json, Encoding.UTF8, "application/json");
            var creat      = _httpClientFactory.CreateClient();

            creat.BaseAddress = new Uri(_configuration["URLAPI:Url"]);
            var post = await creat.PostAsync("api/Product/CreatWholePrice", jsonstring);

            return(post.IsSuccessStatusCode);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> CreatWholePrice(string Value, int productId)
        {
            var list    = JsonConvert.DeserializeObject <List <CreatWholePrice> >(Value);
            var request = new CreatWholePriceViewModel()
            {
                ProductId = productId,
                ListCreat = list
            };
            var creat = await _productConnectAPI.CreatWholePrice(request);

            return(Json(new
            {
                status = true,
            }));
        }
Ejemplo n.º 4
0
        public async Task <int> CreatWholePrice(CreatWholePriceViewModel request)
        {
            var listwholePrice = await _context.WholePrices.Where(x => x.ProductId == request.ProductId).ToListAsync();

            foreach (var remove in listwholePrice)
            {
                _context.WholePrices.Remove(remove);
            }

            foreach (var product in request.ListCreat)
            {
                var wolePrice = new WholePrice()
                {
                    ProductId    = request.ProductId,
                    FromQuantity = product.FromQuantity,
                    ToQuantity   = product.ToQuantity,
                    Price        = product.Price
                };
                _context.WholePrices.Add(wolePrice);
            }
            return(await _context.SaveChangesAsync());
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> CreatWholePrice([FromBody] CreatWholePriceViewModel request)
        {
            var creat = await _productSerVice.CreatWholePrice(request);

            return(Ok());
        }