/// <summary>
 /// Method for creating new card and prepare new account.
 /// </summary>
 /// <param name="card">Card, which need create.</param>
 /// <param name="userId">Id of current user</param>
 public static void CreateCard(Card card, string userId, IRepositoryFactory factory)
 {
     card.Number = new string(card.Number.Where(c=>c!=' ').ToArray());
     var account = new Account
     {
         Balance = 0,
         Card = card,
         CreationDate = DateTime.Now,
         IsBlocked = false,
         UserId = userId
     };
     factory.AccountRepository.Add(account);
 }
 public void Edit(Account item)
 {
     _db.Entry(item).State = EntityState.Modified;
     /*var old = FindById(item.AccountId);
     old.Balance = item.Balance;
     old.Card = item.Card;
     old.Balance = item.Balance;
     old.IsBlocked = item.IsBlocked;
     old.Operations.Clear();
     foreach (var tag in item.Operations)
         old.Operations.Add(tag);*/
     _db.SaveChanges();
 }
 private static string FormatAccountName(Account a)
 {
     return string.Format("{0} - {1} грн. (**{2})", a.Card.Name, a.Balance,
         a.Card.Number.Substring(a.Card.Number.Length - 4));
 }
 public void Add(Account item)
 {
     _db.Accounts.Add(item);
     _db.SaveChanges();
 }