public ApiResult <T> GetAll <T>() where T : List <DeclarationItem> { return(cache.GetOrCreate("Declaration_GetAll_" + currentLang, entry => { entry.SlidingExpiration = TimeSpan.FromMinutes(60); return inner.GetAll <T>(); })); }
public ApiResult <T> GetAll <T>() where T : List <DeclarationItem> { var result = inner.GetAll <T>(); if (!result.Succeeded && LogError || result.Succeeded && LogGetSucceeded || stopwatch.ElapsedMilliseconds > LogLongTime) { logRepository.Add(new LogItem(stopwatch, userId, Guid.Empty, result.GetApiResutlt(), null, null, result.Data)); } return(result); }
public async Task <IActionResult> Declarations(string id) { var customer = await userManager.FindByIdAsync(id); var declarations = await declarationRepository.GetAll(); var customerDeclares = declarations.Where(d => d.UserId == id).ToList(); CustomerDeclarationsViewModel model = new CustomerDeclarationsViewModel(); model.Declarations = customerDeclares; return(View(model)); }
public async Task <ActionResult> DeleteAdmin(string id) { var user = await userManager.FindByIdAsync(id); var balances = await balanceRepository.GetAll(); //Delete user balance var userBalance = balances.FirstOrDefault(b => b.UserId == user.Id); if (userBalance != null) { var deleteBalanceResult = await balanceRepository.Delete(userBalance.Id); } //Delete user orders var orders = await orderRepository.GetAll(); var userOrders = orders.Where(o => o.UserId == user.Id).ToList(); if (userOrders.Count > 0) { foreach (var order in userOrders) { await orderRepository.Delete(order.Id); } } //Delete user declares var declares = await declarationRepository.GetAll(); var userDeclares = declares.Where(o => o.UserId == user.Id).ToList(); if (userDeclares.Count > 0) { foreach (var declaration in userDeclares) { await declarationRepository.Delete(declaration.Id); } } //Delete user var result = await userManager.DeleteAsync(user); if (result.Succeeded) { return(Json(new { success = true, message = "Deleted !" })); } return(Json(new { success = false, message = "Error appeared !" })); }
public ApiResult <List <DeclarationItem> > GetAll() { return(HandleRequest <List <DeclarationItem> >() ?? declarationRepository.GetAll <List <DeclarationItem> >()); }