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)); }
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)); }
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"); }
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"); }
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)); }
public void TestFail(string a) { PhoneNumber10 pn = new PhoneNumber10(); Assert.False(pn.IsValid(a)); }
public void TestPass(string a) { PhoneNumber10 pn = new PhoneNumber10(); Assert.True(pn.IsValid(a)); }