Example #1
0
        public ActionResult Create(UserProfile userprofile)
        {
            if (ModelState.IsValid)
            {
                db.UserProfiles.Add(userprofile);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(userprofile);
        }
        public ActionResult Create(UserProfile userprofile)
        {
            if (ModelState.IsValid)
            {
                userprofile.EvaluationKey = LogPathStatics.GenerateEvaluationKey(userprofile.UserName, userprofile.Company, userprofile.Email);
                userprofile.PermanentKey = LogPathStatics.GeneratePermanentKey(userprofile.UserName, userprofile.Company, userprofile.Email);
                db.UserProfiles.Add(userprofile);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(userprofile);
        }
Example #3
0
 public ActionResult Edit(UserProfile userprofile)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userprofile).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(userprofile);
 }
        // Created to send an email containing the key information
        // E.g. http://localhost:19986/UserProfiles2/RequestEvaluationKey2?username=Kane+Marshall&company=Clinical+Solutions&email=kane.marshall%40clinicalsolutions.com
        public bool RequestEvaluationKey2(string username = "", string company = "", string email = "")
        {
            UserProfile userprofile = new UserProfile();
            userprofile.UserName = username;
            userprofile.Company = company;
            userprofile.Email = email;
            // How many instances of the above exists right now?

            int entries = db.UserProfiles.Where(user => user.Email == email && user.Company == company && user.UserName == username).Count();
            if (entries == 0)
            {
                userprofile.EvaluationKey = LogPathStatics.GenerateEvaluationKey(username, company, email);
                userprofile.PermanentKey = LogPathStatics.GeneratePermanentKey(username, company, email);
                db.UserProfiles.Add(userprofile);
                db.SaveChanges();
            }
            else
            {
                try
                {
                    UserProfile previous = db.UserProfiles.Where(user => user.Email == email && user.Company == company && user.UserName == username).First();
                    LogPathStatics.SendEmail(email, "Your evaluation key", previous.EvaluationKey);
                }
                catch (Exception)
                {
                    return false;
                }
            }
            return true;
        }