public ActionResult KullaniciKayit(Customers model)
        {
            try
            {
                bool success;
                using (var customerBusiness = new CustomersBusiness())
                {
                    success = customerBusiness.InsertCustomer(new Customers()
                    {
                        Ad           = model.Ad,
                        Soyad        = model.Soyad,
                        Adres        = model.Adres,
                        KullaniciAdi = model.KullaniciAdi,
                        Sifre        = model.Sifre,
                        Telefon      = model.Telefon,
                        Email        = model.Email
                    });
                }
                var message = success ? "done" : "failed";

                Console.WriteLine("Operation " + message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error happened: " + ex.Message);
            }
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public ActionResult KullaniciGiris(Customers model)
        {
            try
            {
                Customers musteri = null;
                using (var musteriBusiness = new CustomersBusiness())
                {
                    musteri = musteriBusiness.CustomerLogin(model.KullaniciAdi, model.Sifre);
                }
                if (musteri != null)
                {
                    Session.Add("Musteri", musteri);
                }
                List <Arac> arac = null;
                using (var aracBusiness = new AracBusiness())
                {
                    arac = aracBusiness.SelectAllMusaitArac();
                    Session.Add("Arac", arac);
                }

                return(RedirectToAction("KullaniciSayfasi", "Kullanici"));
            }
            catch (Exception)
            {
                return(View("KullaniciGiris"));
            }
        }
 public bool Transfer(int senderId, int receiverId, decimal amount)
 {
     try
     {
         using (var transactionBussiness = new TransactionBusiness())
         {
             Transactions transaction = new Transactions()
             {
                 TransactorAccountNumber = senderId,
                 ReceiverAccountNumber   = receiverId,
                 TransactionAmount       = amount,
                 TransactionDate         = DateTime.Now,
                 isSuccess = false
             };
             using (var customerBussiness = new CustomersBusiness())
             {
                 return(transactionBussiness.MakeTransaction(transaction, customerBussiness.SelectCustomerById(senderId), customerBussiness.SelectCustomerById(receiverId)));
             }
         }
     }
     catch (Exception e)
     {
         LogHelper.Log(LogTarget.File, "Transfer failed betweeen: " + senderId + " and " + receiverId + "." + "\n" + ExceptionHelper.ExceptionToString(e));
         return(false);
     }
 }
        public bool Withdraw(int senderId, decimal amount)
        {
            try
            {
                using (var transactionBussiness = new TransactionBusiness())
                {
                    Transactions transaction = new Transactions()
                    {
                        TransactorAccountNumber = senderId,
                        ReceiverAccountNumber   = null,
                        TransactionAmount       = amount,
                        TransactionDate         = DateTime.Now,
                        isSuccess = false
                    };

                    using (var customerBussiness = new CustomersBusiness())
                    {
                        return(transactionBussiness.WithdrawMoney(transaction, customerBussiness.SelectCustomerById(senderId)));
                    }
                }
            }
            catch (Exception e)
            {
                LogHelper.Log(LogTarget.File, "Withdraw failed: " + senderId + "." + "\n" + ExceptionHelper.ExceptionToString(e));
                return(false);
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            //控制台会输出SQL语句

            CustomersBusiness customersBusiness = new CustomersBusiness();
            var result = customersBusiness.GetCustomersList(c => 1 == 1);

            foreach (var v in result)
            {
                Console.WriteLine(v.CompanyName);
            }
            Console.ReadLine();
        }
 public Customers SelectCustomerById(int id)
 {
     try
     {
         using (var business = new CustomersBusiness())
         {
             return(business.SelectCustomerById(id));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 public Customers[] SelectAllCustomers()
 {
     try
     {
         using (var business = new CustomersBusiness())
         {
             return(business.SelectAllCustomers().ToArray());
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 public bool DeleteCustomer(int id)
 {
     try
     {
         using (var business = new CustomersBusiness())
         {
             business.DeleteCustomerById(id);
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public bool UpdateCustomer(Customers entity)
 {
     try
     {
         using (var business = new CustomersBusiness())
         {
             business.UpdateCustomer(entity);
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public CustomersController()
 {
     cb = new CustomersBusiness();
 }
Example #11
0
 public CustomersController()
 {
     this.business = new CustomersBusiness();
 }