示例#1
0
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Address,Address2,City,State,ZipCode,Latitude,Longitude,PhoneNumber1,PhoneNumber2,EmailAddress,LastModifiedBy,LastModifiedDateTime,Name")] Tech model)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser user = new ApplicationUser {
                    UserName = model.EmailAddress, Email = model.EmailAddress, FirstName = model.FirstName, LastName = model.LastName, IsConfirmed = true
                };
                ApplicationDbContext.SCreateUser(user, "cfi12345", "Tech");
                model.UserId = user.Id;

                model.LastModifiedById     = User.Identity.GetUserId();
                model.LastModifiedDateTime = DateTime.Now;
                try
                {
                    model.PhoneNumber1 = PhoneNumber10.Reformat(model.PhoneNumber1);
                    model.PhoneNumber2 = PhoneNumber10.Reformat(model.PhoneNumber2);
                    db.Teches.Add(model);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                }
                return(RedirectToAction("Edit2", "Tech", new { id = model.UserId }));
            }

            return(View(model));
        }
示例#2
0
        public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Address,Address2,City,State,ZipCode,Latitude,Longitude,PhoneNumber1,PhoneNumber2,EmailAddress,LastModifiedBy,LastModifiedDateTime,Name")] Tech model)
        {
            if (ModelState.IsValid)
            {
                Tech tech2 = db.Teches.Find(model.UserId);
                tech2.FirstName            = model.FirstName;
                tech2.Address              = model.Address;
                tech2.Address2             = model.Address2;
                tech2.City                 = model.City;
                tech2.PhoneNumber1         = PhoneNumber10.Reformat(model.PhoneNumber1);
                tech2.PhoneNumber2         = PhoneNumber10.Reformat(model.PhoneNumber2);
                tech2.LastModifiedById     = User.Identity.GetUserId();
                tech2.LastModifiedDateTime = DateTime.Now;
                tech2.LastName             = model.LastName;
                tech2.Latitude             = model.Latitude;
                tech2.Longitude            = model.Longitude;
                tech2.State                = model.State;
                tech2.ZipCode              = model.ZipCode.Trim();
//				db.Entry(model).State = EntityState.Modified;
                try
                {
                    db.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                }

                return(RedirectToAction("Edit2", "Tech", new { id = model.UserId }));
            }
            return(View(model));
        }
示例#3
0
        public void PhoneNumberRegEx13()
        {
            string input = "234.567.8901";
            bool   b     = Regex.IsMatch(input, PhoneNumber10.RegEx, RegexOptions.IgnoreCase);

            Assert.IsTrue(b, input);
            string t = PhoneNumber10.Reformat(input);

            Assert.AreEqual(t, "(234) 567-8901");
        }
示例#4
0
        public void PhoneNumberRegEx11()
        {
            string input = "234.567.8901 ext 8888";
            bool   b     = Regex.IsMatch(input, PhoneNumber10.RegEx, RegexOptions.IgnoreCase);

            Assert.IsFalse(b, input);
            string t = PhoneNumber10.Reformat(input);

            Assert.AreEqual(t, "ERROR");
        }
示例#5
0
        public async Task <ActionResult> Edit([Bind(Include = "NickName,Address1,Address2,City,State,Zip,SSN,Email,SMTPEmail,ReceiveCallNotes,UserId,Active,PhoneNumber1,PhoneNumber2")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                employee.PhoneNumber1    = PhoneNumber10.Reformat(employee.PhoneNumber1);
                employee.PhoneNumber2    = PhoneNumber10.Reformat(employee.PhoneNumber2);
                db.Entry(employee).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.UserId = new SelectList(db.AspNetUsers, "Id", "UserName", employee.UserId);
            return(View(employee));
        }
示例#6
0
        public void TestFail(string a)
        {
            PhoneNumber10 pn = new PhoneNumber10();

            Assert.False(pn.IsValid(a));
        }
示例#7
0
        public void TestPass(string a)
        {
            PhoneNumber10 pn = new PhoneNumber10();

            Assert.True(pn.IsValid(a));
        }