public string CreateProfile(ProfileModel ProfileModel)
        {
            string regStatus = "";
             try
             {
                 using (EventsDbEntities eventsContext = new EventsDbEntities())
                 {
                     T_LOGIN loginEntity = new T_LOGIN();
                     loginEntity.UserName = ProfileModel.UserName;
                     loginEntity.Password = ProfileModel.Password;
                     loginEntity.CreatedBy = "System";
                     loginEntity.CreatedOn = DateTime.Now;
                     eventsContext.T_LOGIN.Add(loginEntity);

                     T_PROFILE_DETAILS profilesEntity = new T_PROFILE_DETAILS();
                     profilesEntity.FirstName = ProfileModel.FirstName;
                     profilesEntity.LastName = ProfileModel.LastName;
                     profilesEntity.LoginId = loginEntity.LoginId;
                     eventsContext.T_PROFILE_DETAILS.Add(profilesEntity);
                     eventsContext.SaveChanges();

                 }
                 regStatus = "Success";

             }
             catch (Exception ex)
             {
                 throw ex;
                 regStatus = "Error occured";
             }
             return regStatus;
        }
 public ActionResult EditProfile(ProfileModel model)
 {
     model.UpdateProfile(model);
     return RedirectToAction("Logout");
 }
 public ActionResult EditProfile()
 {
     ProfileModel model = new ProfileModel();
     model = model.GetProfile(User.Identity.Name);
     return View(model);
 }
 public ActionResult ProfileCreate(ProfileModel ProfileModel)
 {
     if (ModelState.IsValid)
     {
        string regStats =  ProfileModel.CreateProfile(ProfileModel);
        if (regStats == "Success")
        {
            return RedirectToAction("ThankYou");
        }
        else
        {
            return View();
        }
     }
     else
     {
         return View();
     }
 }
        public ProfileModel GetProfile(string userName)
        {
            ProfileModel model = new ProfileModel();
             if (!String.IsNullOrWhiteSpace(userName))
             {
                 using (EventsDbEntities eventsContext = new EventsDbEntities())
                 {
                     T_LOGIN loginDetails = eventsContext.T_LOGIN.FirstOrDefault(login => login.UserName == userName);
                     T_PROFILE_DETAILS profileDetails = eventsContext.T_PROFILE_DETAILS.FirstOrDefault(profile => profile.LoginId == loginDetails.LoginId);
                     model.FirstName = profileDetails.FirstName;
                     model.LastName = profileDetails.LastName;
                     model.Password = loginDetails.Password;
                     model.cnfmPassword = loginDetails.Password;
                     model.UserName = userName;

                 }
             }
              return model;
        }
        public void UpdateProfile(ProfileModel model)
        {
            using (EventsDbEntities eventsContext = new EventsDbEntities())
             {
                 T_LOGIN loginDetails = eventsContext.T_LOGIN.FirstOrDefault(login => login.UserName == model.UserName);
                 T_PROFILE_DETAILS profileDetails = eventsContext.T_PROFILE_DETAILS.FirstOrDefault(profile => profile.LoginId == loginDetails.LoginId);
                 profileDetails.FirstName = model.FirstName;
                 profileDetails.LastName = model.LastName;
                 loginDetails.Password = model.Password;
                 eventsContext.SaveChanges();

             }
        }