public async Task <ActionResult> AddProductToInventory(int LocationID, int ProductID) { try{ var item = _service.GetAllLocations().Select(location => location).Where(location => location.LocationID == LocationID).FirstOrDefault(); if ((await _AuthorizationService.AuthorizeAsync(User, item, new ClaimsAuthorizationRequirement("Owner", new List <string> { item.LocationID.ToString() }))).Succeeded) { _service.AddProductToInventory(LocationID, ProductID, 0); return(RedirectToAction("Admin", new{ id = LocationID })); } }catch (Exception ex) { Log.Debug("Adding Product to invetory failed,{0}\n{1}", ex.Message, ex.StackTrace); } return(RedirectToAction(nameof(Index))); }