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, })); }
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); }
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, })); }
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()); }
public async Task <IActionResult> CreatWholePrice([FromBody] CreatWholePriceViewModel request) { var creat = await _productSerVice.CreatWholePrice(request); return(Ok()); }