예제 #1
0
        public void SearchCustomerByNameShouldReturnProfile()
        {
            // arrange
            List <CProduct> supply = new List <CProduct>
            {
                new CProduct("111", "Banana", "Produce", 0.5, 10),
                new CProduct("222", "orange", "Produce", 0.88, 10)
            };
            List <CProduct> p = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 4),
                new CProduct("222", "orange", "Produce", 0.88, 4)
            };
            CStore    store    = new CStore("Phoenix101", "606", supply);
            CCustomer customer = new CCustomer("123123121", "John", "Smith", "6021111111");

            COrder order = new COrder(store, customer, DateTime.Today, 100, p);

            customer.PlaceOrder(store, order);
            ISearch searchTool = new SimpleSearch();
            // act
            string customerid;
            bool   result = searchTool.SearchByName(store, "John", "Smith", out customerid);


            // assert
            Assert.True(result);
        }
예제 #2
0
        private static string CheckAndAddOneCustomer(StoreRepository repo, string storeLoc, CStore store, ISearch ss)
        {
            Console.WriteLine("What is the customer's first name?");
            string firstname = ValidateNotNull(Console.ReadLine());

            Console.WriteLine("What is the customer's last name?");
            string lastname = ValidateNotNull(Console.ReadLine());

            Console.WriteLine("What is the customer's phone number?");
            string phonenumber = ValidatePhonenumber(Console.ReadLine());
            string customerid;
            // or use repo.GetOneCustomerByNameAndPhone, check null reference
            // can delay setting up customer profiles
            // by name or by name and phone
            bool Found = ss.SearchByNameAndPhone(store, firstname, lastname, phonenumber, out customerid);

            if (Found)
            {
                Console.WriteLine($"Dear Customer, you already have a profile with us, here is your customer id {customerid}");
            }
            else
            {
                // new customer has no order history atm
                customerid = CIDGen.Gen();
                CCustomer newCustomer = new CCustomer(customerid, firstname, lastname, phonenumber);
                store.AddCustomer(newCustomer);
                repo.StoreAddOneCusomter(storeLoc, newCustomer);
                Console.WriteLine($"Dear {customerid}, your profile has been set up successfuly");
            }
            return(customerid);
        }
예제 #3
0
            public CCustomer GetResultSetToCS(DataRow dr)
            {
                CCustomer oCS = new CCustomer();

                oCS.Cust_OId      = CUtils.GetDBValue(dr, 0, "-1").ToString();
                oCS.Cust_Branch   = CUtils.GetDBValue(dr, 1, string.Empty).ToString();
                oCS.Cust_Id       = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 2, string.Empty).ToString());
                oCS.Cust_Name     = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 3, string.Empty).ToString());
                oCS.Cust_CSType   = (ECSType)Enum.Parse(typeof(ECSType), CUtils.GetDBValue(dr, 4, string.Empty).ToString());
                oCS.Cust_ContactP = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 5, string.Empty).ToString());
                oCS.Cust_Address  = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 6, string.Empty).ToString());
                oCS.Cust_Cell     = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 7, string.Empty).ToString());
                oCS.Cust_Phone    = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 8, string.Empty).ToString());
                oCS.Cust_Email    = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 9, string.Empty).ToString());
                oCS.Cust_Fax      = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 10, string.Empty).ToString());
                oCS.Cust_Web      = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 11, string.Empty).ToString());
                oCS.Cust_IsActive = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 12, "N").ToString());
                oCS.Cust_DiscRate = float.Parse(CUtils.GetDBValue(dr, 13, float.MinValue.ToString()).ToString());

                oCS.Creator      = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 14, string.Empty).ToString());
                oCS.CreationDate = DateTime.Parse(CUtils.GetDBValue(dr, 15, "12/12/2007").ToString());
                oCS.UpdateBy     = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 16, string.Empty).ToString());
                oCS.UpdateDate   = DateTime.Parse(CUtils.GetDBValue(dr, 17, "12/12/2007").ToString());

                return(oCS);
            }
예제 #4
0
        public void CustomerWithProfileFailedToPlaceAnOrder()
        {
            List <CProduct> supply = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 10),
                new CProduct("222", "orange", "Produce", 0.88, 10)
            };
            List <CProduct> p = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 20),
                new CProduct("222", "orange", "Produce", 0.88, 20)
            };
            CStore    store    = new CStore("Phoenix101", "606", supply);
            CCustomer customer = new CCustomer("123123121", "John", "Smith", "6021111111");
            COrder    order    = new COrder(store, customer, DateTime.Today, 100, p);

            // customer has an existing profile
            store.AddCustomer(customer);
            customer.PlaceOrder(store, order);

            // inventory should not be updated 10-20<0 => 10
            foreach (var item in store.Inventory)
            {
                Assert.Equal(10, item.Value.Quantity);
            }

            // userDict should have customer file, but with no order history
            Assert.Empty(store.CustomerDict["123123121"].OrderHistory);
        }
예제 #5
0
        /// <summary>
        /// Update Customer Contact State
        /// </summary>
        /// <param name="id">id</param>
        /// <param name="ContactState">Contact State from 1 to 3</param>
        /// <returns>HttpStatusCode</returns>
        public IHttpActionResult Put([FromBody] PutCustomer customer)
        {
            if (customer.Id > 0 && customer.ContactState > 0 && customer.ContactState < 4) //verificate input data
            {
                ISession session = NHibernateHelper.GetCurrentSession();
                try
                {
                    ITransaction tx = session.BeginTransaction();

                    CCustomer customerToUpdate = session.Query <CCustomer>() //select current customer from DB
                                                 .Where(p => p.Id == customer.Id)
                                                 .FirstOrDefault();

                    customerToUpdate.ContactState = customer.ContactState; //set ContactState from PUT entity to DB entity

                    session.Update(customerToUpdate);                      //update customer

                    tx.Commit();
                }
                catch (Exception e)
                {
                    //throw new Exception("",e);
                    return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "špatné parametry")));
                }
                finally
                {
                    session.Close();
                }
            }
            else
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "neplatné parametry")));
            }
            return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.OK, "změna proběhla v pořádku")));
        }
예제 #6
0
    protected void imgLogin_Click(object sender, ImageClickEventArgs e)
    {
        CCustomer customer = Global.GetStore().CustomerMgr.FindByName(txtName.Text.Trim());

        if (customer == null)
        {
            RegisterStartupScript("starup", "<script>alert('用户不存在!');</script>");
            return;
        }
        if (customer.Pwd != txtPwd.Text)
        {
            RegisterStartupScript("starup", "<script>alert('帐号不正确!');</script>");
            return;
        }
        Session["Customer"] = customer;

        string to = Request["to"];

        if (!string.IsNullOrEmpty(to))
        {
            Response.Redirect(to);
        }
        else
        {
            Response.Redirect("index.aspx");
        }
    }
예제 #7
0
        private CCustomer Getformdata()
        {
            CCustomer occs = new CCustomer();

            //
            occs.Cust_OId      = txtOId.Text;
            occs.Cust_Branch   = currentBranch.CompBrn_Code;
            occs.Cust_Id       = txtId.Text;
            occs.Cust_Name     = txtName.Text;
            occs.Cust_CSType   = ECSType.CUSTOMER;
            occs.Cust_ContactP = txtcontactper.Text;
            occs.Cust_Address  = txtaddress.Text;
            occs.Cust_Cell     = txtcell.Text;
            occs.Cust_Phone    = txtphn.Text;
            occs.Cust_Email    = txtemail.Text;
            occs.Cust_Fax      = txtfax.Text;
            occs.Cust_Web      = txtweb.Text;
            occs.Cust_IsActive = chkIsActive.Checked ? "Y":"N";
            occs.Cust_DiscRate = float.Parse(txtdiscrate.Text);

            occs.Creator      = currentUser.User_OID;
            occs.CreationDate = DateTime.Now;
            occs.UpdateBy     = currentUser.User_OID;
            occs.UpdateDate   = DateTime.Now;

            return(occs);
        }
예제 #8
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (validatedata())
     {
         CCustomerBO occsbo  = new CCustomerBO();
         CCustomer   occs    = new CCustomer();
         CResult     oResult = new CResult();
         occs = Getformdata();
         if (this.txtOId.Text.Trim() == string.Empty)
         {
             oResult = occsbo.Create(occs);
         }
         else
         {
             if (DialogResult.OK == MessageBox.Show("Are you wanted to upadte Customer " + txtName.Text + " ?", "Confirmation!", MessageBoxButtons.OKCancel))
             {
                 oResult = occsbo.Update(occs);
             }
         }
         if (oResult.IsSuccess)
         {
             MessageBox.Show("Message saved succesfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
             clearformdata();
         }
         else
         {
             MessageBox.Show("Message can not be saved", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
예제 #9
0
        public void StoreAddOneCustomer(string storeLoc, CCustomer customer)
        {
            using var context = new Project0databaseContext(_contextOptions);
            // only have this part below in the data model, rest moves to console main
            var newCustomer = new Customer
            {
                Customerid  = customer.Customerid,
                Firstname   = customer.FirstName,
                Lastname    = customer.LastName,
                Phonenumber = customer.PhoneNumber,
                Email       = customer.Email,
            };

            context.Customers.Add(newCustomer);
            context.SaveChanges();

            // many to many, bridge table gets updated as well
            var newBridge = new Storecustomer
            {
                Storeloc   = storeLoc,
                Customerid = customer.Customerid
            };

            context.Storecustomers.Add(newBridge);
            context.SaveChanges();
        }
예제 #10
0
        public void CustomerWithoutProfileFailedToPlaceAnOrder()
        {
            List <CProduct> supply = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 10),
                new CProduct("222", "orange", "Produce", 0.88, 10)
            };
            List <CProduct> p = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 20),
                new CProduct("222", "orange", "Produce", 0.88, 20)
            };
            CStore    store    = new CStore("Phoenix101", "606", supply);
            CCustomer customer = new CCustomer("123123121", "John", "Smith", "6021111111");
            COrder    order    = new COrder(store, customer, DateTime.Today, 100, p);

            customer.PlaceOrder(store, order);

            // inventory should not be updated 10-20<0 => 10
            foreach (var item in store.Inventory)
            {
                Assert.Equal(10, item.Value.Quantity);
            }

            // customer does not have an existing profile
            // a failed order doesn not create a new user profile
            // userDict should be empty
            // .Equal 0 does not check a collection size
            Assert.Empty(store.CustomerDict);
        }
    public void LoadProfile()
    {
        ProfileCommon pcProfile;

        if (this.sUserName.Length > 0)
        {
            pcProfile = this.Profile.GetProfile(this.sUserName);
        }
        else
        {
            pcProfile = this.Profile;
        }

        txtAddressLine1.Text = pcProfile.AddressLine1;
        txtAddressLine2.Text = pcProfile.AddressLine2;
        txtCity.Text         = pcProfile.City;
        txtPostalCode.Text   = pcProfile.PostalCode;

        CCustomer customer =
            CCustomer.GetCustomer(Convert.ToInt32(pcProfile.CustomerID));

        if (customer != null)
        {
            txtFirstName.Text     = customer.Cus_FName;
            txtLastName.Text      = customer.Cus_LName;
            txtContactNumber.Text = customer.Cus_ContactNumber;
            txtRSAID.Text         = customer.Cus_IDNumber;
            imgPicture.ImageUrl   = customer.Cus_ProfilePic;
        }
    }
예제 #12
0
        public string GetCustomer(string InputValue)
        {
            string    strInputValue = CreatePara(InputValue);
            CCustomer customer      = service.GetCustomer(strInputValue);

            return(CJson.SerializeObject(customer));
        }
        public ActionResult AddEditCust(int CustomerID)
        {
            pdsTidRedLiveEntities db   = new pdsTidRedLiveEntities();
            List <custType>       list = db.custType.ToList();

            ViewBag.UserRoleList = new SelectList(list, "custTypeID", "custType1");

            CCustomer model = new CCustomer();

            if (CustomerID > 0)
            {
                customer c = db.customer.SingleOrDefault(x => x.customerID == CustomerID);
                model.customerID = c.customerID;
                model.custTypeID = c.custTypeID;
                model.custName   = c.custName;
                model.address1   = c.address1;
                model.address2   = c.address2;
                model.zipCode    = c.zipCode;
                model.city       = c.city;
                model.email      = c.email;
                model.active     = c.active;
            }
            else
            {
                model.active = true;
            }
            return(PartialView("AddEditCust", model));
        }
예제 #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Customer"] == null)
        {
            Response.Redirect("login.aspx?to=OrderAddr.aspx");
            return;
        }
        m_Customer = (CCustomer)Session["Customer"];

        if (Session["Order"] != null)
        {
            m_Order = (COrder)Session["Order"];
        }

        string delid = Request["delid"];

        if (!string.IsNullOrEmpty(delid))
        {
            m_Order.OrderDetailMgr.Delete(new Guid(delid));
        }

        if (!IsPostBack)
        {
            LoadProvince();

            CAccount account = (CAccount)m_Customer.AccountMgr.GetFirstObj();
            lbAccount.Text = account.Score.ToString();
        }
    }
예제 #15
0
        public List <COrder> GetOneCustomerOrderHistory(CCustomer customer, CStore store)
        {
            using var context = new Project0databaseContext(_contextOptions);
            var customerExist = context.Storecustomers.FirstOrDefault(x => x.Storeloc == store.Storeloc && x.Customerid == customer.Customerid);

            if (customerExist == null)
            {
                return(null);
            }

            List <COrder> OrderHistory = GetAllOrdersOfOneCustomer(customer.Customerid, store, customer);

            // has no order
            if (OrderHistory == null)
            {
                return(null);
            }

            foreach (var order in OrderHistory)
            {
                order.ProductList = GetAllProductsOfOneOrder(order.Orderid);
                order.TotalCost   = store.CalculateTotalPrice(order.ProductList);
            }
            return(OrderHistory);
        }
예제 #16
0
        public ctrlCustomerLimit(UniXP.Common.CProfile objProfile, UniXP.Common.MENUITEM objMenuItem)
        {
            InitializeComponent();
            m_objProfile     = objProfile;
            m_objMenuItem    = objMenuItem;
            m_bIsChanged     = false;
            m_bDisableEvents = false;

            m_objSelectedCustomer = null;
            m_objCreditLimitList  = null;

            cboxCurrency.Properties.Items.Clear();
            List <CCurrency> objCurrencyList = CCurrency.GetCurrencyList(m_objProfile, null);

            if (objCurrencyList != null)
            {
                foreach (CCurrency objCurrency in objCurrencyList)
                {
                    cboxCurrency.Properties.Items.Add(objCurrency);
                }
            }
            objCurrencyList = null;
            if (cboxCurrency.Properties.Items.Count > 0)
            {
                cboxCurrency.SelectedItem = cboxCurrency.Properties.Items[0];
            }
            CheckClientsRight();
        }
예제 #17
0
        public void ResupplyAndReorderReadAndWrite()
        {
            string          path    = "../../../SimplyWriteData.json";
            JsonFilePersist persist = new JsonFilePersist(path);
            CStore          store   = persist.ReadStoreData();

            List <CProduct> supply = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 10),
                new CProduct("222", "orange", "Produce", 0.88, 10),
                new CProduct("333", "Rocket", "Transport", 1000000, 15)
            };

            store.AddProducts(supply);
            CCustomer       customer = new CCustomer("127137147", "Adam", "Savage", "4801111111");
            List <CProduct> p        = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 1),
                new CProduct("222", "orange", "Produce", 0.88, 1)
            };
            COrder order = new COrder(store, customer, DateTime.Today, 100, p);

            customer.PlaceOrder(store, order);

            persist.WriteStoreData(store);
            foreach (var pair in store.Inventory)
            {
                Assert.Equal(15, pair.Value.Quantity);
            }
        }
예제 #18
0
        public CStore GetOneStoreOrderHistory(string storeLoc)
        {
            using var context = new Project0databaseContext(_contextOptions);
            var dbStore = context.Stores.FirstOrDefault(x => x.Storeloc == storeLoc);

            if (dbStore == null)
            {
                return(null);
            }
            // store has no customer profile yet
            CStore seekStore = new CStore(dbStore.Storeloc, dbStore.Storephone);

            seekStore.CustomerDict = GetAllCustomersAtOneStore(storeLoc);

            foreach (var customer in seekStore.CustomerDict)
            {
                CCustomer cust = customer.Value;
                cust.OrderHistory = GetAllOrdersOfOneCustomer(cust.Customerid, seekStore, cust);
                foreach (var order in cust.OrderHistory)
                {
                    order.ProductList = GetAllProductsOfOneOrder(order.Orderid);
                    order.TotalCost   = seekStore.CalculateTotalPrice(order.ProductList);
                }
            }
            return(seekStore);
        }
예제 #19
0
        }// not mapped

        public List <CCustomer> GetAllCustomersAtOneStoreByName(string storeLoc, string firstname, string lastName)
        {
            using var context = new Project0databaseContext(_contextOptions);
            var dbStore = context.Stores.Include(x => x.Storecustomers)
                          .ThenInclude(x => x.Customer)
                          .FirstOrDefault(x => x.Storeloc == storeLoc);

            if (dbStore == null)
            {
                return(null);
            }
            List <CCustomer> customers = new List <CCustomer>();

            foreach (var customer in dbStore.Storecustomers)
            {
                if (customer.Customer.Firstname == firstname && customer.Customer.Lastname == lastName)
                {
                    CCustomer c = new CCustomer(customer.Customer.Customerid, customer.Customer.Firstname,
                                                customer.Customer.Lastname, customer.Customer.Phonenumber, customer.Customer.Email);
                    // these customers have no order history atm
                    customers.Add(c);
                }
            }
            return(customers);
        }// not mapped
예제 #20
0
        public FrmCustInfo(CCustomer customer) : this()
        {
            cust   = customer;
            custID = cust.ID;

            btndel.Enabled          = true;
            txtname.Text            = cust.Code;
            txttel.Text             = cust.Telphone;
            txtpnmb.Text            = cust.PlatNumber;
            txtMobile.Text          = cust.Mobile;
            txtads.Text             = cust.Address;
            txtlct.Text             = cust.LctAddress;
            comboBox1.SelectedIndex = (int)cust.ICCardType;
            txtcode.Text            = cust.ICCardCode;
            if (cust.ICCardStat == EnmICCardStatus.Normal)
            {
                radioButtonNormal.Checked = true;
                radioButtonLoss.Checked   = false;
            }
            else if (cust.ICCardStat == EnmICCardStatus.Lost)
            {
                radioButtonNormal.Checked = false;
                radioButtonLoss.Checked   = true;
            }
            else
            {
                radioButtonNormal.Checked = false;
                radioButtonLoss.Checked   = false;
            }
        }
예제 #21
0
        public ActionResult CustomerCreate(CCustomer c)
        {
            List <CCustomer> lsCustomers = CCustomerFactory.fn顧客查詢();
            CCustomer        ccustomer   = lsCustomers.FirstOrDefault(m => m.fCustomerEmail == c.fCustomerEmail);

            CCustomerFactory.fn顧客新增(c);
            ViewBag.message = "新增成功";
            return(View());
        }
예제 #22
0
 public FrmCustInfo()
 {
     InitializeComponent();
     radioButtonNormal.Checked = true;
     cust                    = new CCustomer();
     btndel.Enabled          = false;
     custID                  = 0;
     comboBox1.SelectedIndex = 1;
 }
예제 #23
0
 private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.ColumnIndex > -1 && e.RowIndex > -1)
     {
         CCustomer cut = (CCustomer)dataGridView1.Rows[e.RowIndex].DataBoundItem;
         new FrmCustInfo(cut).ShowDialog();
         UpdateDataGridView();
     }
 }
예제 #24
0
        public ActionResult CustomerEdit(CCustomer n)
        {
            //int id = Convert.ToInt32(fCustomerId);
            //List<CCustomer> lsCustomers = CCustomerFactory.fn顧客查詢();
            //CCustomer ccustomer = lsCustomers.FirstOrDefault(m => m.fCustomerId == n.fCustomerId);
            //var cus=db.tcus

            return(View());
        }
        public ActionResult Edit(string id, CustomerViewModel viewCustomer)
        {
            string storeLoc = TempData.Peek("adminLoc").ToString();

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", "invalid input format");
                    return(View());
                }

                // concurrent
                CCustomer foundCustomer = _storeRepo.GetOneCustomer(id);
                if (foundCustomer == null)
                {
                    ModelState.AddModelError("", "Another Admin has just deleted this customer");
                    return(View());
                }
                CCredential foundCredential = _storeRepo.GetOneCredential(foundCustomer.Email);
                if (foundCredential == null)
                {
                    ModelState.AddModelError("", "Another Admin has just deleted this email");
                    return(View());
                }


                // if you have changed email
                if (foundCustomer.Email != viewCustomer.Email)
                {
                    // check if the changed email has already been used by someone else
                    CCustomer editedCustomer1 = _storeRepo.GetOneCustomerByEmail(viewCustomer.Email);
                    if (editedCustomer1 != null)
                    {
                        ModelState.AddModelError("", "This email is already in use");
                        return(View());
                    }
                }
                var editedCustomer   = new CCustomer(id, viewCustomer.Firstname, viewCustomer.Lastname, viewCustomer.Phonenumber, viewCustomer.Email);
                var editedCredential = new CCredential(viewCustomer.Email, viewCustomer.Password);
                _storeRepo.DeleteOneCustomer(storeLoc, id);
                _storeRepo.DelelteOneCredential(foundCustomer.Email);
                // drop dependcy issue
                //_storeRepo.EditOneCredential(foundCredential.Email,editedCredential);
                _storeRepo.AddOneCredential(editedCredential);
                _storeRepo.StoreAddOneCustomer(storeLoc, editedCustomer);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "error while trying to edit a customer");
                ModelState.AddModelError("", "failed to edit a customer");
                return(View());
            }
        }
예제 #26
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Customer"] == null)
     {
         Response.Redirect("login.aspx");
         return;
     }
     m_Customer = (CCustomer)Session["Customer"];
     m_Account  = (CAccount)m_Customer.AccountMgr.GetFirstObj();
 }
예제 #27
0
        public void CreateACustomer()
        {
            CStore    store    = new CStore("Phoenix101");
            CCustomer customer = new CCustomer("123123121", "John", "Smith", "6021111111");

            Assert.Equal("123123121", customer.Customerid);
            Assert.Equal("John", customer.FirstName);
            Assert.Equal("Smith", customer.LastName);
            Assert.Equal("6021111111", customer.PhoneNumber);
        }
예제 #28
0
        public void SimulateChangeCustomerChildListProperties(CCustomer objCustomer, enumActionSaveCancel enActionType)
        {
            // Создаем объект, хранящий информацию, которую нужно передать
            // объектам, получающим уведомление о событии
            ChangeCustomerChildListPropertieEventArgs e = new ChangeCustomerChildListPropertieEventArgs(objCustomer, enActionType);

            // Вызываем виртуальный метод, уведомляющий наш объект о возникновении события
            // Если нет типа, переопределяющего этот метод, наш объект уведомит все объекты,
            // подписавшиеся на уведомление о событии
            OnChangeCustomerChildListProperties(e);
        }
예제 #29
0
 public CCreditLimit()
 {
     m_uuidID                = System.Guid.Empty;
     m_objCustomer           = null;
     m_objCompany            = null;
     m_objCurrency           = null;
     m_ApprovedCurrencyValue = 0;
     m_CurrencyValue         = 0;
     m_ApprovedDays          = 0;
     m_Days = 0;
 }
예제 #30
0
        public ActionResult Register(CustomerViewModel viewCustomer)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", "Invalid input format");
                    return(View());
                }

                MailAddress result;
                if (!MailAddress.TryCreate(viewCustomer.Email, out result))
                {
                    ModelState.AddModelError("", "Invalid login format");
                    return(View());
                }

                if (viewCustomer.Password != viewCustomer.ConfirmPassword)
                {
                    ModelState.AddModelError("", "Passwords do not match");
                    return(View());
                }

                CCustomer cCustomer = _storeRepo.GetOneCustomerByEmail(viewCustomer.Email);
                if (cCustomer != null)
                {
                    ModelState.AddModelError("", "This email is already in use, try a different one");
                    return(View());
                }
                else
                {
                    // customer don't type in his ID number, is assigned automatically
                    string customerID = Guid.NewGuid().ToString().Substring(0, 10);

                    cCustomer = new CCustomer(customerID, viewCustomer.Firstname, viewCustomer.Lastname, viewCustomer.Phonenumber, viewCustomer.Email);
                    CCredential cCredential = new CCredential(viewCustomer.Email, viewCustomer.Password);
                    // it is possible that the credential gets in and customer profile not
                    _storeRepo.AddOneCredential(cCredential);
                    _storeRepo.AddOneCustomer(cCustomer);

                    TempData["User"] = cCustomer.Email;
                    TempData.Keep("User");
                    // changed to shopping cart later
                    TempData[cCustomer.Email] = 1;
                }
                return(RedirectToAction("Index", "Store"));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "error while trying to register");
                ModelState.AddModelError("", "failed to register");
                return(View());
            }
        }