Пример #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 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;
                }
            }
        }
Пример #4
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;
         }
     }
 }