Ejemplo n.º 1
0
 /// <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);
 }
Ejemplo n.º 2
0
 public ActionResult Create(Card card)
 {
     if (ModelState.IsValid)
     {
         try
         {
             CardService.CreateCard(card, User.Identity.GetUserId(), _factory);
             TempData["SuccessMessage"] = "Карта успешно добавлена";
             return RedirectToAction("Index", "Home");
         }
         catch (ValidationException e)
         {
             ModelState.AddModelError(e.Property,e.Message);
         }
     }
     return View(card);
 }
Ejemplo n.º 3
0
 public void Edit(Card item)
 {
     _db.Entry(item).State = EntityState.Modified;
     _db.SaveChanges();
 }
Ejemplo n.º 4
0
 public void Add(Card item)
 {
     _db.Cards.Add(item);
     _db.SaveChanges();
 }