コード例 #1
0
        public ActionResult Edit(customer_view customer_view)
        {
            customers_view.Update(customer_view);
            customers_view.Commit();

            return RedirectToAction("Index");
        }
コード例 #2
0
        public ActionResult Create(customer_view customer_view)
        {
            customers_view.Insert(customer_view);
            customers_view.Commit();

            return RedirectToAction("Index");
        }
コード例 #3
0
 public long GetSessionCustomerID(long sessionID)
 {
     customer_view _customer = new customer_view();
     if (GetSessionCustomer(ref _customer, sessionID))
     {
         return (_customer.id);
     }
     else
     {
         return IDnotFound;
     }
 }
コード例 #4
0
        public ActionResult EditCustomer(customer_view customer_form_page)
        {
            var _session = sessionService.GetSession(this.HttpContext, true, false);

            var _person = persons.GetById(customer_form_page.id);

            _person.firstName = customer_form_page.firstName;
            _person.lastName = customer_form_page.lastName;
            _person.mainPhone = customer_form_page.mainPhone;
            _person.email = customer_form_page.email;
            _person.lastUpdate = DateTime.Now;
            persons.Update(_person);
            persons.Commit();

            var _customer = customers.GetById(customer_form_page.id);
            //_customer.ID = _person.ID;
            _customer.cellPhone = customer_form_page.cellPhone;
            _customer.homePhone = customer_form_page.homePhone;
            _customer.faxNumber = customer_form_page.faxNumber;
            _customer.comments = customer_form_page.comments;
            _customer.street = customer_form_page.street;
            _customer.city = customer_form_page.city;
            _customer.postalCode = customer_form_page.postalCode;
            _customer.provinceCode = customer_form_page.provinceCode;
            _customer.countryCode = customer_form_page.countryCode;
            _customer.isEmailReceipt = customer_form_page.isEmailReceipt;
            _customer.isPartyMember = customer_form_page.isPartyMember;
            _customer.lastUpdate = DateTime.Now;
            customers.Update(_customer);
            customers.Commit();

            return RedirectToAction("CustomerDetails", new { id = _customer.ID });
        }
コード例 #5
0
        public ActionResult CreateCustomer(customer_view customer_form_page)
        {
            var _session = sessionService.GetSession(this.HttpContext, true, false);

            //validation check
            var personfirstname = persons.GetAll().Where(s => s.firstName.ToUpper().Contains(customer_form_page.firstName.ToUpper())).ToList();
            var personlastname = persons.GetAll().Where(s => s.lastName.ToUpper().Contains(customer_form_page.lastName.ToUpper())).ToList();
            var personmainphone = persons.GetAll().Where(s => s.mainPhone.ToUpper().Contains(customer_form_page.mainPhone.ToUpper())).ToList();

            var _person = new person();
            _person.firstName = customer_form_page.firstName;
            _person.lastName = customer_form_page.lastName;
            _person.mainPhone = customer_form_page.mainPhone;
            _person.email = customer_form_page.email;

            //first, last name and main phone validation

            if (_person.firstName == null)
            {
                return RedirectToAction("ErrorMessage");
            }
            else if (_person.firstName.Trim().Length > 50)
            {
                return RedirectToAction("ErrorMessage");
            }
            else if (_person.lastName == null)
            {
                return RedirectToAction("ErrorMessage");
            }
            else if (_person.lastName.Trim().Length > 50)
            {
                return RedirectToAction("ErrorMessage");
            }
            else if (_person.mainPhone == null)
            {
                return RedirectToAction("ErrorMessage");
            }
            else if (_person.mainPhone.Trim().Length > 30)
            {
                return RedirectToAction("ErrorMessage");
            }
            //else if (personfirstname.Count() > 0 && personlastname.Count() > 0 && personmainphone.Count() > 0)
            else if (personfirstname.Count() > 0 && personlastname.Count() > 0)
            {
                return RedirectToAction("ErrorMessage");
            }

            _person.createDate = DateTime.Now;
            _person.lastUpdate = DateTime.Now;

            persons.Insert(_person);
            persons.Commit();

            var _customer = new customer();
            _customer.ID = _person.ID;
            _customer.cellPhone = customer_form_page.cellPhone;
            _customer.homePhone = customer_form_page.homePhone;
            _customer.faxNumber = customer_form_page.faxNumber;
            _customer.comments = customer_form_page.comments;
            _customer.street = customer_form_page.street;
            _customer.city = customer_form_page.city;
            _customer.postalCode = customer_form_page.postalCode;
            _customer.provinceCode = customer_form_page.provinceCode;
            _customer.countryCode = customer_form_page.countryCode;
            _customer.isEmailReceipt = customer_form_page.isEmailReceipt;
            _customer.isPartyMember = customer_form_page.isPartyMember;
            _customer.createDate = DateTime.Now;
            _customer.lastUpdate = DateTime.Now;
            customers.Insert(_customer);
            customers.Commit();

            _session.idCustomer = _customer.ID;
            sessions.Update(_session);
            sessions.Commit();

            return RedirectToAction("CustomerDetails", new { id = _customer.ID });
        }
コード例 #6
0
        // GET: /Create
        public ActionResult CreateCustomer()
        {
            var _session = sessionService.GetSession(this.HttpContext, true, false);

            //Dropdown list for country
            countryCodes("CANADA");

            //Dropdown list for province
            provinceCodes("ONTARIO");

            var customer_view = new customer_view();
            return View(customer_view);
        }
コード例 #7
0
 public string GetSessionCustomerNamePhone(long sessionID)
 {
     customer_view _customer = new customer_view();
     if (GetSessionCustomer(ref _customer, sessionID))
     {
         return (_customer.fullName + ", " + _customer.mainPhone);
     }
     else
     {
         return string.Empty;
     }
 }
コード例 #8
0
 private bool GetSessionCustomer(ref customer_view customer, long sessionID)
 {
     // Read customer from session
     session _session = sessions.GetById(sessionID);
     bool customerFound = false;
     try //checks if customer is in database
     {
         customer = customers.GetAll().Where(c => c.id == _session.idCustomer).FirstOrDefault();
         customerFound = !(customer.Equals(default(session)));
     }
     catch (Exception e)
     {
         Console.WriteLine("An error occurred: '{0}'", e);
     }
     // Customer found in database
     return customerFound;
 }
コード例 #9
0
 // GET: /Create
 public ActionResult Create()
 {
     var customer_view = new customer_view();
     return View(customer_view);
 }