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);
     }
 }
Beispiel #2
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);
            }
        }
        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();
                    }
                }
            }
        }