Esempio n. 1
0
        public ActionResult CreateStaff(staff_view staff_form_page)
        {
            var _person = new person();
            _person.firstName = staff_form_page.firstName;
            _person.lastName = staff_form_page.lastName;
            _person.mainPhone = staff_form_page.mainPhone;
            _person.email = staff_form_page.email;
            _person.createDate = DateTime.Now;
            _person.lastUpdate = DateTime.Now;
            persons.Insert(_person);
            persons.Commit();

            var _staff = new staff();
            _staff.ID = _person.ID;
            _staff.role = staff_form_page.role;
            _staff.createDate = DateTime.Now;
            _staff.lastUpdate = DateTime.Now;
            staffs.Insert(_staff);
            staffs.Commit();

            return RedirectToAction("Index");
        }
        public ActionResult CreatePartyMember(partymember_view partymember_form_page)
        {
            var _person = new person();
            _person.firstName = partymember_form_page.firstName;
            _person.lastName = partymember_form_page.lastName;
            _person.mainPhone = partymember_form_page.mainPhone;
            _person.email = partymember_form_page.email;
            _person.createDate = DateTime.Now;
            _person.lastUpdate = DateTime.Now;
            persons1.Insert(_person);
            persons1.Commit();

            var _partymember = new partymember();
            _partymember.ID = _person.ID;
            _partymember.cellPhone = partymember_form_page.cellPhone;
            _partymember.petDescription = partymember_form_page.petDescription;
            _partymember.comments = partymember_form_page.comments;
            _partymember.createDate = DateTime.Now;
            _partymember.lastUpdate = DateTime.Now;
            partymembers.Insert(_partymember);
            partymembers.Commit();

            return RedirectToAction("Index");
        }
        public ActionResult CreatePartyMember(partymember_view partymember_form_page)
        {
            //validation check
            var personfirstname = persons1.GetAll().Where(s => s.firstName.ToUpper().Contains(partymember_form_page.firstName.ToUpper())).ToList();
            var personlastname = persons1.GetAll().Where(s => s.lastName.ToUpper().Contains(partymember_form_page.lastName.ToUpper())).ToList();
            var personmainphone = persons1.GetAll().Where(s => s.mainPhone.ToUpper().Contains(partymember_form_page.mainPhone.ToUpper())).ToList();

            var _person = new person();
            _person.firstName = partymember_form_page.firstName;
            _person.lastName = partymember_form_page.lastName;
            _person.mainPhone = partymember_form_page.mainPhone;
            _person.email = partymember_form_page.email;
            _person.createDate = DateTime.Now;
            _person.lastUpdate = DateTime.Now;

            //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");
            }

            persons1.Insert(_person);
            persons1.Commit();

            var _partymember = new partymember();
            _partymember.ID = _person.ID;
            _partymember.cellPhone = partymember_form_page.cellPhone;
            _partymember.petDescription = partymember_form_page.petDescription;
            _partymember.comments = partymember_form_page.comments;
            _partymember.createDate = DateTime.Now;
            _partymember.lastUpdate = DateTime.Now;
            partymembers.Insert(_partymember);
            partymembers.Commit();

            return RedirectToAction("Index");
        }
Esempio n. 4
0
        public ActionResult CreateStaff(staff_view staff_form_page)
        {
            sessionService.GetSessionID(this.HttpContext, true, true);

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


            var _person = new person();
            _person.firstName = staff_form_page.firstName;
            _person.lastName = staff_form_page.lastName;
            _person.mainPhone = staff_form_page.mainPhone;
            _person.email = staff_form_page.email;
            _person.password = sessionService.GetHash("012345");
            _person.createDate = DateTime.Now;
            _person.lastUpdate = DateTime.Now;

            //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");
            }

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

            var _staff = new staff();
            _staff.ID = _person.ID;
            _staff.role = staff_form_page.role;
            _staff.createDate = DateTime.Now; 
            _staff.lastUpdate = DateTime.Now;
            staffs.Insert(_staff);
            staffs.Commit();

            return RedirectToAction("Index");
        }
Esempio n. 5
0
        public ActionResult SelectUser(string userEmail, string userPassword, string P1, string P2)
        {

            SelectionOptionID user = new SelectionOptionID(IDnotFound, "");
            person _person = new person();

            if (userEmail != null && userPassword != null)
            {
                var _session = sessionService.GetSession(this.HttpContext, false, false);
                bool personFound = false;
                bool userAuthor = false;

                string xP1 = _session.sessionGUID.Substring(0, 12);
                string xP2 = _session.sessionGUID.Substring(11, 12);

                if (P1 == xP1 && P2 == xP2)
                {
                    try //checks if person is in database
                    {
                        _person = persons.GetAll().Where(u => u.email == userEmail).
                            FirstOrDefault();
                        personFound = !(_person.Equals(default(person)));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("An error occurred: '{0}'", e);
                    }
                }
                // Person found in database
                if (personFound)
                {
                    userAuthor = sessionService.VerifyHash(_person.ID, userPassword);
                }
                // User is authorized
                if (userAuthor)
                {
                    user.ID = _person.ID;
                    user.Label = userEmail;
                    _session.idStaff = user.ID;
                }
                else
                {
                    user.ID = IDnotFound;
                    user.Label = string.Empty;
                    _session.idStaff = null;
                }
                sessions.Update(_session);
                sessions.Commit();
            }
            return Json(user);
        }
Esempio n. 6
0
        public ActionResult ResetPassword(long personID)
        {
            var sessionID = sessionService.GetSessionID(this.HttpContext, true, true);
            person _person = new person();
            bool personFound = false;

            try //checks if person is in database
            {
                _person = persons.GetById(personID);
                personFound = !(_person.Equals(default(person)));
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: '{0}'", e);
            }

            // Person has been found, reset password
            if (personFound)
            {
                _person.password = sessionService.GetHash("012345");
                persons.Update(_person);
                persons.Commit();
            }

            return RedirectToAction("ResetPassword","Staff");
        }
        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 });
        }