Esempio n. 1
0
        public CustomerBO Update(CustomerBO cust)
        {
            using (var uow = facade.UnitOfWork)
            {
                var customerFromDb = uow.CustomerRepository.Get(cust.Id);
                if (customerFromDb == null)
                {
                    throw new InvalidOperationException("Customer not found");
                }

                var customerUpdated = conv.Convert(cust);
                customerFromDb.FirstName = customerUpdated.FirstName;
                customerFromDb.LastName  = customerUpdated.LastName;
                customerFromDb.Addresses.RemoveAll(ca => !customerUpdated.Addresses
                                                   .Exists(a => a.AddressId == ca.AddressId && a.CustomerId == ca.CustomerId));

                customerUpdated.Addresses.RemoveAll(
                    ca => customerFromDb.Addresses.Exists(
                        a => a.AddressId == ca.AddressId &&
                        a.CustomerId == ca.CustomerId));

                customerFromDb.Addresses.AddRange(
                    customerUpdated.Addresses);

                uow.Complete();
                return(conv.Convert(customerFromDb));
            }
        }
        public void TestUpdateCustomer()
        {
            this.GetMemoContext().Database.EnsureDeleted();
            CustomerBO customer1 = new CustomerBO()
            {
                Id        = 1,
                Firstname = "Bo",
                Lastname  = "Jensen",
                Address   = "Skolevej 3",
                ZipCode   = 4510,
                City      = "Dumby",
                Email     = "*****@*****.**",
                CVR       = 12345678
            };

            customer1 = GetService().Create(customer1);
            Assert.AreEqual(GetService().GetAll().Count, 1);
            customer1.Firstname = "Knud";
            customer1.Lastname  = "Hansen";
            customer1.Address   = "Byvej 393";
            customer1.ZipCode   = 1111;
            customer1.City      = "Randers";
            customer1.Email     = "*****@*****.**";
            customer1.Phone     = 1234456; //new
            customer1.CVR       = 98765432;
            this.GetService().Update(customer1);
            Assert.AreEqual("Knud", this.GetService().Get(1).Firstname);
            Assert.AreEqual("Hansen", this.GetService().Get(1).Lastname);
            Assert.AreEqual("Byvej 393", this.GetService().Get(1).Address);
            Assert.AreEqual(1111, this.GetService().Get(1).ZipCode);
            Assert.AreEqual("Randers", this.GetService().Get(1).City);
            Assert.AreEqual("*****@*****.**", this.GetService().Get(1).Email);
            Assert.AreEqual(98765432, this.GetService().Get(1).CVR);
            Assert.AreEqual(1234456, this.GetService().Get(1).Phone);
        }
Esempio n. 3
0
        public void GetCustomersByFirstName()
        {
            string          FirstName;
            CustomerBO      customerBO = new CustomerBO();
            List <Customer> customers  = new List <Customer>();

            // 1 from last name
            FirstName = "Fred";

            customers = customerBO.GetCustomersByFirstName(FirstName);

            Assert.AreEqual(customers.Count, 1);

            // 1 from last name
            FirstName = "re";

            customers = customerBO.GetCustomersByFirstName(FirstName);

            Assert.AreEqual(customers.Count, 0);

            // 0 from last name
            FirstName = "";

            customers = customerBO.GetCustomersByFirstName(FirstName);

            Assert.AreEqual(customers.Count, 0);

            // 0 from last name
            FirstName = null;

            customers = customerBO.GetCustomersByFirstName(FirstName);

            Assert.AreEqual(customers.Count, 0);
        }
Esempio n. 4
0
        public CustomerBO Update(CustomerBO Cust)
        {
            using (var uow = facade.UnitOfWork)
            {
                Customer CustUpdated = converter.Convert(Cust);

                Customer CustFromDb = uow.CustomerRepository.Get(CustUpdated.Id);
                if (CustFromDb == null)
                {
                    throw new InvalidOperationException("Customer Not Found !");
                }
                //remove from customer Database the addresses does not exist in updated customer
                CustFromDb.Addresses
                .RemoveAll(x => !CustUpdated.Addresses.Exists(ca => ca.AddressId == x.AddressId && ca.CustomerId == x.CustomerId));

                //remove from updated customer the addresses that already exists in database
                CustUpdated.Addresses.RemoveAll(x => CustFromDb.Addresses.Exists(ca => ca.AddressId == x.AddressId && ca.CustomerId == x.CustomerId));

                //add the rest of addresses that are new to customer address
                CustFromDb.Addresses.AddRange(CustUpdated.Addresses);

                uow.complete();

                return(converter.Convert(CustFromDb));
            }
        }
        private void FillDropDowns()
        {
            cblPrintingType.Attributes.Add("onclick", "radioMe(event);");

            lbOrderId.Text = this.OrderId.ToString();
            MemberBO mem = this.MemberService.GetMemberByOrder(this.OrderId);

            if (mem != null)
            {
                lbBusinessMan.Text = mem.FullName;
            }
            CustomerBO cust = this.CustomerService.GetCustomerByOrder(this.OrderId);

            if (cust != null)
            {
                lbCustomer.Text = string.Format("Tên: {0}, Địa chỉ: {1}, SĐT: {2}", cust.Name, cust.Address, cust.Telephone);
            }
            //Printing Type
            List <PrintingTypeBO> printingTypes = this.OrderService.GetAllPrintingType();

            cblPrintingType.Items.Clear();
            foreach (PrintingTypeBO pt in printingTypes)
            {
                cblPrintingType.Items.Add(new ListItem(pt.Name, pt.Id.ToString()));
            }
            string defaultPrintingTypeCode = this.SettingService.GetStringSetting(Constant.Setting.Default_PrintingType_Code);

            cblPrintingType.SelectedValue = this.OrderService.GetPrintTypeByCode(defaultPrintingTypeCode).Id.ToString();
        }
Esempio n. 6
0
        public void SearchCustomersByLastName()
        {
            string          LastName;
            CustomerBO      customerBO = new CustomerBO();
            List <Customer> customers  = new List <Customer>();

            // 2 from last name
            LastName = "Flintstone";

            customers = customerBO.SearchCustomersByLastName(LastName);

            Assert.AreEqual(customers.Count, 2);

            // 2 from last name
            LastName = "Flint";

            customers = customerBO.SearchCustomersByLastName(LastName);

            Assert.AreEqual(customers.Count, 2);

            // 0 from last name
            LastName = "";

            customers = customerBO.SearchCustomersByLastName(LastName);

            Assert.AreEqual(customers.Count, 3);

            // 0 from last name
            LastName = null;

            customers = customerBO.SearchCustomersByLastName(LastName);

            Assert.AreEqual(customers.Count, 0);
        }
Esempio n. 7
0
        public List <CustomerBO> searchCustomer()
        {
            List <CustomerBO> list = new List <CustomerBO>();
            FileStream        fin  = new FileStream("customerdata.txt", FileMode.Open);
            StreamReader      sr   = new StreamReader(fin);
            String            line;

            while ((line = sr.ReadLine()) != null)
            {
                String[] data = line.Split(';');

                CustomerBO cust = new CustomerBO();
                cust.Custid  = int.Parse(data[0]);
                cust.Name    = data[1];
                cust.Address = data[2];
                cust.Phone   = data[3];
                cust.Email   = data[4];
                cust.Slimit  = int.Parse(data[5]);
                cust.Amount  = double.Parse(data[6]);

                list.Add(cust);
            }


            sr.Close();
            fin.Close();

            return(list);
        }
Esempio n. 8
0
        public int InsertCustomer(CustomerBO customer)
        {
            using (var context = new InThuDoEntities())
            {
                Customer cust = new Customer()
                {
                    Name           = customer.Name,
                    Telephone      = customer.Telephone,
                    Address        = customer.Address,
                    Email          = customer.Email,
                    CreatedOn      = customer.CreatedOn,
                    CreatedBy      = customer.CreatedBy,
                    Company        = customer.Company,
                    PhoneNumber    = customer.PhoneNumber,
                    FaxNumber      = customer.FaxNumber,
                    TaxCode        = customer.TaxCode,
                    Note           = customer.Note,
                    CustomerTypeId = customer.CustomerTypeId
                };

                context.Customers.Add(cust);
                context.SaveChanges();
                return(cust.CustomerId);
            }
        }
Esempio n. 9
0
        private CustomerBO MapCustomer(Customer c)
        {
            if (c == null)
            {
                return(null);
            }

            CustomerBO cust = new CustomerBO()
            {
                CustomerId     = c.CustomerId,
                Name           = c.Name,
                Telephone      = c.Telephone,
                Address        = c.Address,
                Email          = c.Email,
                CreatedOn      = c.CreatedOn,
                CreatedBy      = c.CreatedBy,
                LastEditedOn   = c.LastEditedOn,
                LastEditedBy   = c.LastEditedBy,
                Company        = c.Company,
                PhoneNumber    = c.PhoneNumber,
                FaxNumber      = c.FaxNumber,
                TaxCode        = c.TaxCode,
                Note           = c.Note,
                CustomerTypeId = c.CustomerTypeId,
                CustomerType   = new CustomerTypeBO()
                {
                    Id          = c.LibCustomerType.Id,
                    Code        = c.LibCustomerType.Code,
                    Name        = c.LibCustomerType.Name,
                    Description = c.LibCustomerType.Description
                }
            };

            return(cust);
        }
        public void TestDeleteCustomer()
        {
            this.GetMemoContext().Database.EnsureDeleted();
            CustomerBO customer1 = new CustomerBO()
            {
                Firstname = "Bo",
                Lastname  = "Jensen",
                Address   = "Skolevej 3",
                ZipCode   = 4510,
                City      = "Dumby",
                Email     = "*****@*****.**",
                CVR       = 12345678
            };

            customer1 = GetService().Create(customer1);
            Assert.AreEqual(GetService().GetAll().Count, 1);
            CustomerBO customer2 = new CustomerBO()
            {
                Firstname = "Lars",
                Lastname  = "Jensen",
                Address   = "Skolevej 3",
                ZipCode   = 4510,
                City      = "Dumby",
                Email     = "*****@*****.**",
                CVR       = 12345678
            };

            customer2 = GetService().Create(customer2);
            Assert.AreEqual(GetService().GetAll().Count, 2);
            GetService().Delete(customer2.Id);
            Assert.AreEqual(GetService().GetAll().Count, 1);
            Assert.AreEqual(GetService().Get(customer1.Id).Firstname, "Bo");
        }
Esempio n. 11
0
        void Grid_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
        {
            if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove)
            {
                objMaster = new CustomerBO();

                try
                {
                    objMaster.GetByPrimaryKey(grdLister.CurrentRow.Cells["Id"].Value.ToInt());
                    objMaster.Delete(objMaster.Current);


                    PopulateData();
                }
                catch (Exception ex)
                {
                    if (objMaster.Errors.Count > 0)
                    {
                        ENUtils.ShowMessage(objMaster.ShowErrors());
                    }
                    else
                    {
                        ENUtils.ShowMessage(ex.Message);
                    }
                    e.Cancel = true;
                }
            }
        }
Esempio n. 12
0
        public CustomerBO search(int id)
        {
            CustomerBO   customer = new CustomerBO();
            FileStream   fin      = new FileStream("customerdata.txt", FileMode.Open);
            StreamReader sr       = new StreamReader(fin);
            String       line;

            while ((line = sr.ReadLine()) != null)
            {
                String[] data = line.Split(';');
                if (int.Parse(data[0]) == id)
                {
                    customer.Custid  = int.Parse(data[0]);
                    customer.Name    = data[1];
                    customer.Address = data[2];
                    customer.Phone   = data[3];
                    customer.Email   = data[4];
                    customer.Slimit  = int.Parse(data[5]);
                    customer.Amount  = double.Parse(data[6]);

                    break;
                }
            }

            sr.Close();
            fin.Close();

            return(customer);
        }
Esempio n. 13
0
        public Transactions DepositCash(CustomerBO cbo, decimal amount) //used to deposit a cash into a customer account
        {                                                               //firstly creates a transaction of deposit type and then add amount in the balance
            Transactions ts = new Transactions {
                Type = "deposited", DT = DateTime.Now, UserID = cbo.UserID, Balance = amount
            };
            MainDAL dal = new MainDAL();   //of cbo who is current user.

            dal.CreateTrasaction(ts);
            List <CustomerBO> old     = CustomerDecryption();
            List <CustomerBO> newList = new List <CustomerBO>();
            CustomerBO        tempBo  = new CustomerBO();

            foreach (CustomerBO u in old)
            {
                if (u.AccountNo == cbo.AccountNo)
                {
                    u.Balance = u.Balance + amount;
                }
                tempBo = u;
                tempBo = CustomerEncryption(tempBo);
                newList.Add(tempBo);
            }
            dal.RestoreCustomerAccounts(newList);
            return(ts);
        }
Esempio n. 14
0
 public IHttpActionResult GetCustomer(string mobile)
 {
     try
     {
         var customer = new CustomerBO().GetCustomer(new Customer {
             MobileNo = mobile
         });
         if (customer != null)
         {
             return(Ok(new
             {
                 MobileNo = customer.MobileNo,
                 Name = customer.Name,
                 EmailID = customer.EmailId,
                 Status = UTILITY.SUCCESSTATUS
             }));
         }
         else
         {
             return(Ok(new { MobileNo = "", Name = "", EmailID = "", Status = UTILITY.FAILURESTATUS }));
         }
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
Esempio n. 15
0
        public ActionResult ViewCustomer(int?customerId, string customerType)
        {
            Logger.Debug("ViewCustomer|Selected Customer ID: " + customerId);

            if (customerId != null)
            {
                if (Constants.GetEnumDescription(CustomerType.Individual).Equals(customerType))
                {
                    Session["SessionCustomer"] =
                        (IIndividualCustomerVO)CustomerBO.RetrieveIndividualCustomer(customerId ?? default(int));
                }
                else
                {
                    Session["SessionCustomer"] =
                        (ICompanyCustomerVO)CustomerBO.RetrieveCompanyCustomer(customerId ?? default(int));
                }
            }

            if (Constants.GetEnumDescription(CustomerType.Individual).Equals(customerType))
            {
                return(RedirectToAction("ViewIndividualDetails"));
            }

            return(RedirectToAction("ViewCompanyDetails"));
        }
Esempio n. 16
0
        public Transactions WithdrawCash(CustomerBO cbo, decimal amount) //first it creates transaction of withdraw type
        {                                                                //and then get the decrypted customers in a list and decrement
            Transactions ts = new Transactions {
                Type = "withdrawn", DT = DateTime.Now, UserID = cbo.UserID, Balance = amount
            };
            MainDAL dal = new MainDAL();                    //amount from balance of that customer who is cbo.

            dal.CreateTrasaction(ts);
            List <CustomerBO> list    = new List <CustomerBO>();
            List <CustomerBO> newList = new List <CustomerBO>();

            list = CustomerDecryption();
            CustomerBO tempcbo = new CustomerBO();

            foreach (CustomerBO u in list)
            {
                if (u.UserID == cbo.UserID)
                {
                    u.Balance = u.Balance - amount;
                }
                tempcbo = u;
                tempcbo = CustomerEncryption(tempcbo);
                newList.Add(tempcbo);
            }
            dal.RestoreCustomerAccounts(newList);
            return(ts);
        }
Esempio n. 17
0
        // GET: api/Customer/5
        public HttpResponseMessage Get(string name)
        {
            CustomerRepository repo = new CustomerRepository();

            Data.customer customer = repo.GetbyField(name);
            if (customer != null)
            {
                CustomerBO customerBO = new CustomerBO();
                customerBO.CustomerKey   = customer.custkey;
                customerBO.CustId        = customer.custid;
                customerBO.CustName      = customer.custname;
                customerBO.CustomerGroup = customer.customergroup;
                customerBO.CreditLimit   = customer.creditlimit;
                customerBO.CreditStatus  = customer.creditstatus;
                var address = new AddressRepository().GetbyId(customer.addrkey);
                customerBO.Address = new AddressBO()
                {
                    Address1 = address.address1,
                    Address2 = address.address2,
                    City     = address.city,
                    State    = address.state,
                    Zip      = address.zipcode,
                    Email    = address.email,
                    Phone    = address.phone,
                    Fax      = address.fax
                };

                return(Request.CreateResponse(HttpStatusCode.OK, customerBO, Configuration.Formatters.JsonFormatter));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Not found", Configuration.Formatters.JsonFormatter));
            }
        }
Esempio n. 18
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        CustomerBO ObjCus = new CustomerBO();
        ObjCus.Email = txtUsername.Text.Trim();
        ObjCus.Password = txtPassword.Text.Trim();
        ObjCus = DAL.CheckUserCredentials(ObjCus);
        if (!string.IsNullOrEmpty(txtUsername.Text) && !string.IsNullOrEmpty(txtPassword.Text))
        {
            if (ObjCus != null&& ObjCus.CustomerID>0)
            {
                Constants.sessionVaribles.UserID = ObjCus.CustomerID;
                txtUsername.Text = string.Empty;
                ltUserName.Text = string.Empty;
                Constants.sessionVaribles.Fullname = ObjCus.FirstName;
                ltUserName.Text = ObjCus.FirstName;
                liEditAcc.Visible = true;
                liCreateAcc.Visible = false;
                ltMsg.Text=string.Empty;
            }
            else
            {

                ltMsg.Text = "Invalied Username";
            }
        }
        else
        { ltMsg.Text = "Enter Username and password"; }
    }
Esempio n. 19
0
        public void DisplayBalance()        //to display current user balance.
        {
            MainBLL    bll = new MainBLL();
            CustomerBO ub  = bll.GetCurrentUser(null, null, cbo.AccountNo);

            WriteLine($"\nAccount #{ub.AccountNo}\nDate: {DateTime.Now}\nBalance: {ub.Balance}");
        }
Esempio n. 20
0
        public void PrintReceipt(Transactions ts, CustomerBO ub)
        {
            MainBLL bll = new MainBLL();

            ub = bll.GetCurrentUser(null, null, ub.AccountNo);
            WriteLine($"\nAccount #{ub.AccountNo}\nDate: {ts.DT}\n\n{ts.Type.ToUpper()}: {ts.Balance}\nBalance: {ub.Balance}");
        }
Esempio n. 21
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     CustomerBO ObjCus = new CustomerBO();
     ObjCus.FirstName = txtFirstName.Text.Trim();
     ObjCus.LastName = txtLastName.Text.Trim();
     ObjCus.Email = txtEmailID.Text.Trim();
     ObjCus.Password = txtPSW.Text;
     ObjCus.Phone = txtPhone.Text.Trim();
     ObjCus.Fax = txtFax.Text.Trim();
     ObjCus.BillingAddress1 = txtBillAdd1.Text.Trim();
     if (!string.IsNullOrEmpty(txtBillAdd2.Text))
         ObjCus.BillingAddress2 = txtBillAdd2.Text.Trim();
     ObjCus.Country = txtCountry.Text.Trim();
     ObjCus.City = txtCity.Text.Trim();
     ObjCus.State = txtState.Text.Trim();
     ObjCus.ZipCode = txtZipCode.Text.Trim();
     if (cusID > 0)
     {
         ObjCus.CustomerID = cusID;
         DAL.UpdateCustomerRegDet(ObjCus);
         ltMess.Text = "Updated Sunccessfully";
     }
     else
     {
         cusID = DAL.InsertCustomerDet(ObjCus);
         ltMess.Text = "Inserted Sunccessfully";
         Constants.sessionVaribles.UserID = cusID;
     }
     ClearHistory();
 }
Esempio n. 22
0
        public void DeleteExistingAccount() //to delete an account of customer based on the account number inputed by
        {                                   //admin.
            WriteLine("DELETE EXISTING ACCOUNT\n\n");
            int AccNo = 0;

d1:
            Write("Enter the account number you want to delete: ");
            string tmp    = ReadLine();
            bool   isTrue = AccountNumberValidations(tmp, ref AccNo);

            if (!isTrue)
            {
                goto d1;
            }
            CustomerBO tempDelete = new CustomerBO();

            tempDelete = bll.GetCurrentUser(null, null, AccNo);
            Write($"You wish to delete the account held by {tempDelete.Name}; If this information is correct please re - enter the account number: ");
            int cnfrmAcc = int.Parse(ReadLine());

            if (AccNo == cnfrmAcc)
            {
                bll.DeleteRecord(tempDelete);
            }
            else
            {
                WriteLine("=> Confirmation of Account Number Failed");
                goto d1;
            }
        }
Esempio n. 23
0
 public IHttpActionResult GetCustomer(string mobile)
 {
     try
     {
         var customer = new CustomerBO()
                        .GetCustomer(new Customer
         {
             MobileNo = mobile
         });
         if (customer != null)
         {
             return(Ok(new
             {
                 MobileNo = customer.MobileNo,
                 Name = customer.Name,
                 EmailID = customer.EmailID
             }));
         }
         else
         {
             return(NotFound());
         }
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
        public CustomerBO Update(CustomerBO c)
        {
            using (var uow = facade.UnitOfWork)
            {
                var customerFromDb = uow.CustomerRepository.Get(c.Id);
                if (customerFromDb == null)
                {
                    throw new InvalidOperationException("Customer not found!");
                }
                var customerUpdated = conv.Convert(c);
                customerFromDb.FirstName = customerUpdated.FirstName;
                customerFromDb.LastName  = customerUpdated.LastName;
                customerFromDb.Address   = customerUpdated.Address;

                //1. Remove every customerId and AddressId that does not exists in DBContext
                customerFromDb.Addresses.RemoveAll(
                    ca => !customerUpdated.Addresses.Exists(
                        a => a.AddressId == ca.AddressId &&
                        a.CustomerId == ca.CustomerId));

                //2. Remove all ids that are already in database
                customerUpdated.Addresses.RemoveAll(
                    ca => customerFromDb.Addresses.Exists(
                        a => a.AddressId == ca.AddressId &&
                        a.CustomerId == ca.CustomerId));

                //3. Add all new customerAddresses not yet seen in the DB
                customerFromDb.Addresses.AddRange(
                    customerUpdated.Addresses);

                uow.Complete();
                return(conv.Convert(customerFromDb));
            }
        }
Esempio n. 25
0
        public Transactions CashTransfer(CustomerBO cbo, decimal amount, int accNo) //used to transfer cash just like withdraw
        {                                                                           //creates a transaction of transfer type and then decrease the balance from the
            Transactions ts = new Transactions {
                Type = "transfered", DT = DateTime.Now, UserID = cbo.UserID, Balance = amount
            };
            MainDAL dal = new MainDAL();    //cbo's balance and increase in the balance of customer whose account number is

            dal.CreateTrasaction(ts);       //accNo.
            List <CustomerBO> list    = new List <CustomerBO>();
            List <CustomerBO> newList = new List <CustomerBO>();

            list = CustomerDecryption();
            CustomerBO tempcbo = new CustomerBO();

            foreach (CustomerBO u in list)
            {
                if (u.AccountNo == cbo.AccountNo)
                {
                    u.Balance = u.Balance - amount;
                }
                if (u.AccountNo == accNo)
                {
                    u.Balance = u.Balance + amount;
                }
                tempcbo = u;
                tempcbo = CustomerEncryption(tempcbo);
                newList.Add(tempcbo);
            }
            dal.RestoreCustomerAccounts(newList);
            return(ts);
        }
Esempio n. 26
0
        public IHttpActionResult Login(Customer customer)
        {
            try
            {
                var token = new CustomerLogInBO().CustomerLogIn(customer.MobileNo, customer.Password);

                if (!string.IsNullOrWhiteSpace(token))
                {
                    var _customer = new CustomerBO().GetCustomer(new Customer {
                        MobileNo = customer.MobileNo
                    });
                    if (_customer.IsOTPVerified)
                    {
                        return(Ok(new
                        {
                            token = token
                        }));
                    }
                    else
                    {
                        return(Ok("OTP not Verified...!"));
                    }
                }

                else
                {
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Esempio n. 27
0
        public CustomerBO UpdateSingleRecord(CustomerBO cbo, List <string> strList) //To update single record i.e. if the
        {                                                                           //any entry in the string list is empty then save the old data in it
            CustomerBO insidecbo = new CustomerBO();                                //else write the new data in the particular record.

            insidecbo = cbo;
            if (strList[0] != "")
            {
                insidecbo.Login = strList[0];
            }
            if (strList[1] != "")
            {
                insidecbo.UserID = strList[1];
            }
            if (strList[2] != "")
            {
                insidecbo.Pin = strList[2];
            }
            if (strList[3] != "")
            {
                insidecbo.Name = strList[3];
            }
            if (strList[4] != "")
            {
                insidecbo.Type = strList[4];
            }
            if (strList[5] != "")
            {
                insidecbo.Balance = uint.Parse(strList[5]);
            }
            if (strList[6] != "")
            {
                insidecbo.Status = strList[6];
            }
            return(insidecbo);
        }
Esempio n. 28
0
        public IHttpActionResult UpdateCustomer(string mobile, Customer customer)
        {
            try
            {
                var customerBO  = new CustomerBO();
                var customerObj = customerBO.GetCustomer(new Customer {
                    MobileNo = mobile
                });
                if (customerObj != null)
                {
                    customerObj.Name     = customer.Name;
                    customerObj.EmailID  = customer.EmailID;
                    customerObj.Password = customer.Password;

                    var result = customerBO.SaveCustomer(customerObj);
                    if (result)
                    {
                        return(Ok(UTILITY.SUCCESSMSG));
                    }
                    else
                    {
                        return(BadRequest());
                    }
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Esempio n. 29
0
        public void DeleteRecord(CustomerBO cbo)                                                         //used to delete record. if the given record for deletion is the only
        {                                                                                                //only recors in the file then simply deletes it and write 'empty' to the file
            string            filePath = Path.Combine(Environment.CurrentDirectory, "UserAccounts.csv"); //else simply makes a new list
            List <CustomerBO> listUser = new List <CustomerBO>();                                        //of customers and store all old data into the new list except the
            List <CustomerBO> newList  = new List <CustomerBO>();                                        //record which we want to delete. and update the new list to file.

            listUser = CustomerDecryption();
            int     total = 0;
            MainDAL dal   = new MainDAL();

            foreach (CustomerBO b in listUser)
            {
                total++;
            }
            if (total == 1)
            {
                cbo.Login = "******";
                newList.Add(cbo);
                dal.RestoreCustomerAccounts(newList);
            }
            else
            {
                CustomerBO currentcbo = new CustomerBO();
                foreach (CustomerBO tmp in listUser)
                {
                    if (tmp.AccountNo != cbo.AccountNo)
                    {
                        currentcbo = CustomerEncryption(tmp);
                        newList.Add(currentcbo);
                    }
                }
                dal.RestoreCustomerAccounts(newList);
            }
        }
Esempio n. 30
0
        public void CreateCustomerAccount(CustomerBO cbo)   //used to create userr by just encrypting it and giving it to
        {                                                   //dal layer.
            CustomerEncryption(cbo);
            MainDAL dll = new MainDAL();

            dll.CreateCustomerAccount(cbo);
        }
Esempio n. 31
0
        public IHttpActionResult Login(Customer customer)
        {
            try
            {
                var token = new CustomerLogInBO().CustomerLogIn(customer.MobileNo, customer.Password);

                if (!string.IsNullOrWhiteSpace(token))
                {
                    var _customer = new CustomerBO().GetCustomer(new Customer {
                        MobileNo = customer.MobileNo
                    });
                    if (_customer.IsOTPVerified)
                    {
                        return(Ok(new
                                  { Token = token, Status = UTILITY.SUCCESSTATUS }));
                    }
                    else
                    {
                        return(Ok(new { Token = "", Status = UTILITY.FAILURESTATUS }));
                    }
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Esempio n. 32
0
        public IHttpActionResult CreateCustomer(Customer customer)
        {
            try
            {
                customer.OTP             = GenerateOTP();
                customer.IsOTPVerified   = false;
                customer.OTPSendDate     = DateTime.Now;
                customer.OTPVerifiedDate = null;

                var result = new CustomerBO().SaveCustomer(customer);
                if (result)
                {
                    SendOTP(customer.MobileNo, customer.OTP);
                    return(Ok(UTILITY.SUCCESSMSG));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Esempio n. 33
0
 public ActionResult ForgetPassword(NailShop.Business.Model.ModelWeb.ForgetPassword model)
 {
     string Password = GeneratePassword();
         ICustomer cls = new CustomerBO();
         if (cls.ForgetPassword(model.Email, Password))
         {
             string body = string.Format(Resources.EmailTemplate.ForgetPasswordBody, model.Email, Password);
             this.SendEmailMessage(model.Email, Resources.EmailTemplate.ForgetPasswordSubject, body);
             ViewBag.Message = Resources.ChangePassword.msgSendEmailSucess;
         }
         else
             ViewBag.Message = Resources.ChangePassword.msgNoteError;
         return View(model);
 }
Esempio n. 34
0
 public static CustomerBO CheckUserCredentials(CustomerBO ObjCus)
 {
     using (SqlConnection Conn = new SqlConnection("server=SURESHJALAJA-PC;database=Parking;uid=sa;password=suresh;"))
     {
         using (SqlCommand Cmd = new SqlCommand(Constants.Proc.USP_CHEK_LOGINDETAIALS, Conn))
         {
             Cmd.CommandType = CommandType.StoredProcedure;
             Cmd.Parameters.Add("@UserName", SqlDbType.VarChar).Value = ObjCus.Email;
             Cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = ObjCus.Password;
             Conn.Open();
             using (SqlDataReader dr = Cmd.ExecuteReader())
             {
                 while (dr.Read())
                 {
                     ObjCus.CustomerID = Convert.ToInt32(dr["UserID"]);
                     ObjCus.FirstName = Convert.ToString(dr["FullName"]);
                     ObjCus.Password = Convert.ToString(dr["Password"]);
                 }
             }
         }
     }
     return ObjCus;
 }
Esempio n. 35
0
    public static int InsertCustomerDet(CustomerBO ObjCus)
    {
        int CusID = default(int);
        using (SqlConnection Conn = new SqlConnection("server=SURESHJALAJA-PC;database=Parking;uid=sa;password=suresh;"))
        {
            using (SqlCommand Cmd = new SqlCommand(Constants.Proc.USP_REG_INSERT_CUSTOMERDET, Conn))
            {
                Cmd.CommandType = CommandType.StoredProcedure;
                Cmd.Parameters.AddWithValue("@FirstName", SqlDbType.VarChar).Value = ObjCus.FirstName;
                Cmd.Parameters.AddWithValue("@LastName", SqlDbType.VarChar).Value = ObjCus.LastName;
                Cmd.Parameters.AddWithValue("@Email", SqlDbType.VarChar).Value = ObjCus.Email;
                Cmd.Parameters.AddWithValue("@Password", SqlDbType.VarChar).Value = ObjCus.Password;
                Cmd.Parameters.AddWithValue("@Phone", SqlDbType.VarChar).Value = ObjCus.Phone;
                Cmd.Parameters.AddWithValue("@Fax", SqlDbType.VarChar).Value = ObjCus.Fax;
                Cmd.Parameters.AddWithValue("@BillingAddress1", SqlDbType.VarChar).Value = ObjCus.BillingAddress1;
                if (!string.IsNullOrEmpty(ObjCus.BillingAddress2))
                    Cmd.Parameters.AddWithValue("@BillingAddress2", SqlDbType.VarChar).Value = ObjCus.BillingAddress2;
                Cmd.Parameters.AddWithValue("@Country", SqlDbType.VarChar).Value = ObjCus.Country;
                Cmd.Parameters.AddWithValue("@City", SqlDbType.VarChar).Value = ObjCus.City;
                Cmd.Parameters.AddWithValue("@State", SqlDbType.VarChar).Value = ObjCus.State;
                Cmd.Parameters.AddWithValue("@ZipCode", SqlDbType.VarChar).Value = ObjCus.ZipCode;
                Cmd.Parameters.AddWithValue("@CustomerID", SqlDbType.Int).Direction = ParameterDirection.Output;
                Conn.Open();

                Cmd.ExecuteNonQuery();
                CusID = Convert.ToInt32(Cmd.Parameters["@CustomerID"].Value);
            }
        }
        return CusID;
    }
Esempio n. 36
0
 public JsonResult Login(Business.Model.ModelWeb.LoginModel model)
 {
     ICustomer _customer = new CustomerBO();
         Customer data = _customer.Login(model.LoginName, model.Password);
         if (data != null)
         {
             _session.IsLogin = true;
             _session.IsStore = false;
             _session.CustomerID = data.CustomerID;
             _session.FullName = data.FullName;
             _session.StoreID = data.StoreID;
             return Json(new { IsOk = true }, JsonRequestBehavior.AllowGet);
         }
         return Json(new { IsOk = false }, JsonRequestBehavior.AllowGet);
 }
Esempio n. 37
0
    //public static void InsertOrders(OrderBO ObjOrd)
    //{
    //    using (SqlConnection Conn = new SqlConnection("server=SURESHJALAJA-PC;database=Parking;uid=sa;password=suresh;"))
    //    {
    //        using (SqlCommand Cmd = new SqlCommand(Constants.Proc.USP_INSERT_ORDERS, Conn))
    //        {
    //            Cmd.CommandType = CommandType.StoredProcedure;
    //            Cmd.Parameters.AddWithValue("@UserID", SqlDbType.Int).Value = ObjOrd.UserID;
    //            Cmd.Parameters.AddWithValue("@CatLocationID", SqlDbType.Int).Value = ObjOrd.CatLocationID;
    //            Cmd.Parameters.AddWithValue("@Price", SqlDbType.Decimal).Value = ObjOrd.Price;
    //            Conn.Open();
    //            Cmd.ExecuteNonQuery();
    //        }
    //    }
    //}
    public static CustomerBO GetUserDetailsByUserID(int UserID)
    {
        CustomerBO ObjCus = null;
        using (SqlConnection Conn = new SqlConnection("server=SURESHJALAJA-PC;database=Parking;uid=sa;password=suresh;"))
        {
            using (SqlCommand Cmd = new SqlCommand(Constants.Proc.USP_GET_REGDETAILSBYUSERID, Conn))
            {
                Cmd.CommandType = CommandType.StoredProcedure;
                Cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = UserID;

                Conn.Open();
                using (SqlDataReader dr = Cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        ObjCus = new CustomerBO();
                        ObjCus.FirstName = Convert.ToString(dr["FirstName"]);
                        ObjCus.LastName = Convert.ToString(dr["LastName"]);
                        ObjCus.Email = Convert.ToString(dr["Email"]);
                        ObjCus.Password = Convert.ToString(dr["Password"]);
                        ObjCus.Phone = Convert.ToString(dr["Phone"]);
                        ObjCus.Fax = Convert.ToString(dr["Fax"]);
                        ObjCus.BillingAddress1 = Convert.ToString(dr["BillingAddress1"]);
                        ObjCus.BillingAddress2 = dr["BillingAddress2"] == DBNull.Value ? string.Empty : Convert.ToString(dr["BillingAddress2"]);
                        ObjCus.Country = Convert.ToString(dr["Country"]);
                        ObjCus.City = Convert.ToString(dr["City"]);
                        ObjCus.State = Convert.ToString(dr["State"]);
                        ObjCus.ZipCode = Convert.ToString(dr["ZipCode"]);

                    }

                }
            }
        }
        return ObjCus;
    }
Esempio n. 38
0
        public JsonResult GetdataJS()
        {
            ICustomer _cls = new CustomerBO();
                List<Customer> data = _cls.GetList(s => s.StoreID.Equals(_session.IsLogin));
                var select = from c in data
                             select new { c.CustomerID, c.FullName, c.LocalID, c.LoginName };

                string jsonData = new JavaScriptSerializer().Serialize(select.ToList());
                return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
Esempio n. 39
0
    public static void UpdateCustomerRegDet(CustomerBO ObjCus)
    {
        using (SqlConnection Conn = new SqlConnection("server=SURESHJALAJA-PC;database=Parking;uid=sa;password=suresh;"))
        {
            using (SqlCommand Cmd = new SqlCommand(Constants.Proc.USP_REG_UPDATE_CUSTOMERDET, Conn))
            {
                Cmd.CommandType = CommandType.StoredProcedure;
                Cmd.Parameters.AddWithValue("@UserID", SqlDbType.Int).Value = ObjCus.CustomerID;
                Cmd.Parameters.AddWithValue("@FirstName", SqlDbType.VarChar).Value = ObjCus.FirstName;
                Cmd.Parameters.AddWithValue("@LastName", SqlDbType.VarChar).Value = ObjCus.LastName;
                Cmd.Parameters.AddWithValue("@Email", SqlDbType.VarChar).Value = ObjCus.Email;
                Cmd.Parameters.AddWithValue("@Password", SqlDbType.VarChar).Value = ObjCus.Password;
                Cmd.Parameters.AddWithValue("@Phone", SqlDbType.VarChar).Value = ObjCus.Phone;
                Cmd.Parameters.AddWithValue("@Fax", SqlDbType.VarChar).Value = ObjCus.Fax;
                Cmd.Parameters.AddWithValue("@BillingAddress1", SqlDbType.VarChar).Value = ObjCus.BillingAddress1;
                if (!string.IsNullOrEmpty(ObjCus.BillingAddress2))
                    Cmd.Parameters.AddWithValue("@BillingAddress2", SqlDbType.VarChar).Value = ObjCus.BillingAddress2;
                Cmd.Parameters.AddWithValue("@Country", SqlDbType.VarChar).Value = ObjCus.Country;
                Cmd.Parameters.AddWithValue("@City", SqlDbType.VarChar).Value = ObjCus.City;
                Cmd.Parameters.AddWithValue("@State", SqlDbType.VarChar).Value = ObjCus.State;
                Cmd.Parameters.AddWithValue("@ZipCode", SqlDbType.VarChar).Value = ObjCus.ZipCode;

                Conn.Open();

                Cmd.ExecuteNonQuery();

            }
        }
    }