コード例 #1
0
        public MembershipCreateStatus AddNewCard(ulong nrCard, float srodki, float saldo)
        {
            MembershipCreateStatus status;

            using (var context = new BankSystemEntities())
            {
                try
                {
                    if (context.Cards.Where(c => c.CardNumber == (long)nrCard).Any())
                    {
                        status = MembershipCreateStatus.ProviderError;

                        return(status);
                    }
                    else
                    {
                        var card = new Card()
                        {
                            CardNumber = (long)nrCard,
                            Available  = srodki.ToString(),
                            Balance    = saldo.ToString()
                        };
                        context.Cards.Add(card);
                        context.SaveChanges();
                        status = MembershipCreateStatus.Success;

                        return(status);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
コード例 #2
0
        public MembershipCreateStatus AddCard(string id, string nazwa, ulong nrKarta)
        {
            MembershipCreateStatus status;

            using (var context = new BankSystemEntities())
            {
                try
                {
                    var card = context.Cards.Where(c => c.CardNumber == (long)nrKarta).FirstOrDefault();

                    if (card != null)
                    {
                        card.Name   = nazwa;
                        card.UserId = id;
                        context.SaveChanges();
                        status = MembershipCreateStatus.Success;

                        return(status);
                    }
                    else
                    {
                        status = MembershipCreateStatus.ProviderError;

                        return(status);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
コード例 #3
0
 public List <UserCardsView> GetCardsByAdmin()
 {
     using (var context = new BankSystemEntities())
     {
         try
         {
             return(context.UserCardsViews.ToList());
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
コード例 #4
0
 public List <CardsView> GetCardsWithoutUser()
 {
     using (var context = new BankSystemEntities())
     {
         try
         {
             return(context.CardsViews.Where(c => c.UserId == null).ToList());
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
コード例 #5
0
 public List <TransactionsUsersCardsView> GetTransaktionsByNrCard(ulong nrCard)
 {
     using (var context = new BankSystemEntities())
     {
         try
         {
             return(context.TransactionsUsersCardsViews.Where(c => c.CardNumber == (long)nrCard).ToList());
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
コード例 #6
0
 public List <TransactionsView> GetTransaktionsByUserId(string userId)
 {
     using (var context = new BankSystemEntities())
     {
         try
         {
             return(context.TransactionsViews.Where(c => c.UserId == userId).ToList());
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
コード例 #7
0
 public int GetIdByCardName(string nazwa, string userId)
 {
     using (var context = new BankSystemEntities())
     {
         try
         {
             return
                 (context.UserCardsViews.Where(c => c.UserId == userId && c.CardName == nazwa)
                  .Select(c => c.CardId)
                  .FirstOrDefault());
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
コード例 #8
0
        public MembershipCreateStatus CreateFullTransaktion(string userId, DateTime?data, string tytul, ulong nrCard,
                                                            string name, string miejscowosc, string ulica, string kod, float kwota, float saldo, int id)
        {
            MembershipCreateStatus status;

            using (var context = new BankSystemEntities())
            {
                try
                {
                    var transaction = new Transaction()
                    {
                        UserId  = userId,
                        Date    = data,
                        Title   = " " + tytul + " " + nrCard.ToString() + " " + name + " " + miejscowosc + " " + ulica + " " + kod + " ",
                        Amount  = kwota.ToString(),
                        Balance = saldo.ToString(),
                    };
                    context.Transactions.Add(transaction);

                    var card = context.Cards.Where(c => c.Id == id).FirstOrDefault();

                    if (card != null)
                    {
                        saldo         -= kwota;
                        card.Balance   = saldo.ToString();
                        card.Available = saldo.ToString();
                        context.SaveChanges();
                        status = MembershipCreateStatus.Success;

                        return(status);
                    }
                    else
                    {
                        status = MembershipCreateStatus.ProviderError;

                        return(status);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
コード例 #9
0
 public void GetExistingCard(ulong nrCard, float kwota)
 {
     using (var context = new BankSystemEntities())
     {
         try
         {
             var card =
                 context.Cards.Where(c => c.CardNumber == (long)nrCard).FirstOrDefault();
             var saldo = (float.Parse(card.Balance) + kwota).ToString();
             card.Balance   = saldo;
             card.Available = saldo;
             context.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
     }
 }