示例#1
0
 public ActionResult Verify(string userName, string password)
 {
     using (SemplestEntities dbContext = new SemplestEntities())
     {
         var creds = dbContext.Credentials.Where(c => c.Username == userName && c.Password == password);
         if (creds.Count() == 1)
         {
             Session[Semplest.SharedResources.SEMplestConstants.SESSION_USERID] = creds.First().UsersFK;
             if (creds.First().User.UserRolesAssociations.First().RolesFK == 2)
                 //means this is an admin user
                 return RedirectToAction("Index", "Home");
             else
                 if (creds.First().User.IsRegistered)
                     return RedirectToAction("Index", "Home");
                 else
                 {
                     Semplest.SharedResources.Models.ProfileModel pm = new Models.ProfileModel();
                     pm.UserName = userName;
                     pm.Password1 = password;
                     return PartialView("_Password", pm);
                 }
         }
         Semplest.SharedResources.Models.ProfileModel pm2 = new Models.ProfileModel();
         pm2.UserName = userName + userName;
         pm2.Password1 = password;
         return View(pm2);
     }
 }
示例#2
0
 public ActionResult LogIn(Semplest.SharedResources.Models.ProfileModel pm, string ReturnUrl)
 {
     using (SemplestEntities dbContext = new SemplestEntities())
     {
         Session[Semplest.SharedResources.SEMplestConstants.SESSION_USERID] = 1;
         return RedirectToAction("CampaignSetup", "Campaign");
         var creds = dbContext.Credentials.Where(c => c.Username == pm.UserName && c.Password == pm.Password1);
         if (creds.Count() == 1)
         {
             Credential c = creds.First();
             Session[Semplest.SharedResources.SEMplestConstants.SESSION_USERID] = c.UsersFK;
             if (c.User.UserRolesAssociations.First().RolesFK == 2)
                 //means this is an admin user
                 return RedirectToAction("Index", "Home");
             else if (c.User.IsRegistered)
                 //user is a regular core user
                 return RedirectToAction("CampaignSetup", "Campaign");
             else if (!string.IsNullOrEmpty(pm.SecurityAnswer) && !string.IsNullOrEmpty(pm.SecurityQuestion))
             {
                 //authenticated properly but hasn't registered yet
                 c.SecurityAnswer = pm.SecurityAnswer;
                 c.SecurityQuestion = pm.SecurityQuestion;
                 c.User.IsRegistered = true;
                 dbContext.SaveChanges();
                 return RedirectToAction("Index", "Home");
             }
             else
                 pm.IsRegistered = false;
         }
         return View(pm);
     }
 }
示例#3
0
        public ActionResult ContactUs(SEMCustomerDetail model)
        {
            if (ModelState.IsValid && !(model.CallMe == false && model.EmailMe == false))
            {
                try
                {
                    model.CreatedDate = DateTime.Now;
                    using (SemplestEntities dbContext = new SemplestEntities())
                    {
                        string semEmail = dbContext.Configurations.Select(m => m.DefalutEmailContactMe).FirstOrDefault();

                        if (model.EmailMe == false)
                        {
                            model.email = "";
                        }
                        else if (model.CallMe == false)
                        {
                            model.Phone = "";
                        }
                        dbContext.SEMCustomerDetails.Add(model);
                        dbContext.SaveChanges();

                        // send email using smtp server
                        SendMail(model, semEmail);
                    }
                }
                catch (Exception ex)
                {
                    string errMsg = "Error: " + ex.Message + "\r\n" + ex.StackTrace;
                    ErrorModel errModel = new ErrorModel() { MsgToLog = errMsg, MsgToShow = "Error" };
                    return View("ErrorPage", errModel);
                }
                return RedirectToAction("ThankYou");
            }
            else
            {
                return View(model);
            }
        }
示例#4
0
        public ActionResult Index(string usersearch, string accountnumbersearch, string emailsearch)
        {

            ViewBag.Message = "Welcome to SEMPLEST ADMIN!";
            SemplestEntities dbcontext = new SemplestEntities();

            //FUTURE: add rearch by email and by account number || u.Email.Contains(emailsearch)

            var viewModel =
                from u in dbcontext.Users
                join c in dbcontext.Customers on u.CustomerFK equals c.CustomerPK
                where ((c.Name.Contains(usersearch) || u.FirstName.Contains(usersearch) || u.LastName.Contains(usersearch)) )
                select new HomeModel
                {
                    Customer = c.Name,
                    AccountNumber = c.CustomerPK,
                    FirstName = u.FirstName,
                    LastName = u.LastName,
                    Email = u.Email
                };

            return View(viewModel);
        }
示例#5
0
        public void AddRightToDatabase(string label, string controllerName, string vAction)
        {

            bool found = false;
            string myController = ControllerContext.RouteData.Values["Controller"].ToString();
            string controllerActionName = controllerName + "." + vAction;
            if (controllerName != myController && !string.IsNullOrEmpty(label))
            {
                using (SemplestEntities dbContext = new SemplestEntities())
                {
                    foreach (Right r in dbContext.Rights)
                    {
                        if (label == r.Label && controllerActionName == r.Controller)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        dbContext.Rights.Add(new Right { Controller = controllerActionName, Label = label });
                        dbContext.SaveChanges();
                    }
                }
            }
        }