public async Task Accept_Reject(StoreUsers entity) { var response = await _httpService.Put <StoreUsers>($"{url}/Accept_Reject", entity); if (!response.Success) { throw new ApplicationException(await response.GetBody()); } }
public async Task Seed() { _context.Database.EnsureCreated(); var user = await _userManager.FindByEmailAsync("*****@*****.**"); if (user == null) { user = new StoreUsers() { FirstName = "Trinh", LastName = "Thach", UserName = "******", Email = "*****@*****.**" }; var result = await _userManager.CreateAsync(user, "P@ssw0rd!"); if (result != IdentityResult.Success) { throw new InvalidOperationException("Fail to create default user"); } } if (!_context.Products.Any()) { var filePath = Path.Combine(_hosting.ContentRootPath, "Data/art.json"); var json = File.ReadAllText(filePath); var products = JsonConvert.DeserializeObject <IEnumerable <Product> >(json); _context.Products.AddRange(products); var order = new Order { OrderDate = DateTime.Now, OrderNumber = "12345", User = user, Items = new List <OrderItem>() { new OrderItem { Product = products.First(), Quantity = 5, UnitPrice = products.First().Price } } }; _context.Orders.Add(order); _context.SaveChanges(); } }
public async Task <ActionResult> Accept_Reject(StoreUsers entity) { #region Start the watch var watch = new Stopwatch(); watch.Start(); #endregion var result = await _entityServices.Accept_Reject(entity); #region End the watch watch.Stop(); result.Meta.TotalProcessingTime = watch.ElapsedMilliseconds; #endregion return(Ok(result)); }
public async Task <ApiResponse> Accept_Reject(StoreUsers entity) { try { var entityDB = await _entityRepository.GetByIdAsync(entity.Id); entityDB.Status = entity.Status; await _entityRepository.UpdateAsync(entityDB); return(ApiResponse.Create(HttpStatusCode.OK, null)); } catch (Exception) { return(ApiResponse.Create(HttpStatusCode.InternalServerError, null, "InternalServerError_Error")); } }