public bool DeleteByHeaderId(long header, AccountTypesEnum accountTypesEnum, EntitiesDbContext context) { Safe safe = context.Safes.SingleOrDefault(x => x.HeaderId == header && x.AccountTypeId == (int)accountTypesEnum); if (safe != null) { context.Safes.Remove(safe); context.SaveChanges(); return(true); } return(false); }
public bool DeleteByAccountId(long accountId, AccountTypesEnum accountTypesEnum) { List <Safe> safes = _safeEntity.Where(x => x.AccountId == accountId && x.AccountTypeId == (int)accountTypesEnum).ToList(); if (safes != null) { _safeEntity.RemoveRange(safes); _context.SaveChanges(); return(true); } return(false); }
public BalanceDTO GetBalanceByAccountId(long accountId, AccountTypesEnum accountTypesEnum) { var safes = GetByAccountId(accountId, accountTypesEnum); decimal totalOutcoming = 0; decimal totalIncoming = 0; foreach (Safe safe in safes) { totalOutcoming += safe.Outcoming; totalIncoming += safe.Incoming; } return(new BalanceDTO() { TotalIncoming = totalIncoming, TotalOutcoming = totalOutcoming }); }
public SafeDTO GetByAccountId(long accountId, AccountTypesEnum accountTypesEnum, int currentPage) { var safes = _safeEntity .Where(s => s.AccountId == accountId && s.AccountTypeId == (int)accountTypesEnum) .OrderBy(x => x.Date); return(new SafeDTO() { Total = _safeEntity.Where(s => s.AccountId == accountId && s.AccountTypeId == (int)accountTypesEnum).Count(), List = safes .Skip((currentPage - 1) * PageSettings.PageSize) .Take(PageSettings.PageSize) .AsEnumerable(), TotalIncoming = safes.Sum(x => Math.Ceiling(x.Incoming)), TotalOutcoming = safes.Sum(x => Math.Ceiling(x.Outcoming)) }); }
public bool UpdateByHeaderId(long headerId, decimal total, AccountTypesEnum accountTypesEnum, EntitiesDbContext context) { Safe safe = context.Safes.FirstOrDefault(x => x.HeaderId == headerId && x.AccountTypeId == (int)accountTypesEnum); if (safe != null) { if (accountTypesEnum == AccountTypesEnum.Sellers) { safe.Outcoming = total; } else { safe.Incoming = total; } context.Safes.Update(safe); context.SaveChanges(); return(true); } return(false); }
public JsonResult GetBalanceByAccountId(long accountId, AccountTypesEnum accountTypesEnum) { var safe = Helper.SerializeObject(_safeOperationsRepo.GetBalanceByAccountId(accountId, accountTypesEnum)); return(Json(safe)); }
public IEnumerable <Safe> GetByAccountId(long accountId, AccountTypesEnum accountTypesEnum) { return(_safeEntity.Where(s => s.AccountId == accountId && s.AccountTypeId == (int)accountTypesEnum).AsEnumerable()); }