Example #1
0
        public ActionResult Registration(tblRegistration registrationView)
        {
            bool   statusRegistration  = false;
            string messageRegistration = string.Empty;

            if (ModelState.IsValid)
            {
                // Email Verification
                //string userName = Membership.GetUserNameByEmail(registrationView.Email);
                //if (!string.IsNullOrEmpty(userName))
                //{
                //    ModelState.AddModelError("Warning Email", "Sorry: Email already Exists");
                //    return View(registrationView);
                //}

                //Save User Data
                using (WebAuthenticationEntities dbContext = new WebAuthenticationEntities())
                {
                    var user = new tblRegistration()
                    {
                        Username        = registrationView.Username,
                        FirstName       = registrationView.FirstName,
                        LastName        = registrationView.LastName,
                        Email           = registrationView.Email,
                        Password        = registrationView.Password,
                        ConfirmPassword = registrationView.ConfirmPassword,
                        // ActivationCode = Guid.NewGuid(),
                        ID = registrationView.ID,
                    };

                    var login = new tbllogin()
                    {
                        ID       = registrationView.ID,
                        Username = registrationView.Username,
                        Password = registrationView.Password,
                        Role     = null,
                    };
                    dbContext.tbllogins.Add(login);
                    dbContext.tblRegistrations.Add(user);

                    dbContext.SaveChanges();
                    //dbContext.Entry(user).State = System.Data.Entity.EntityState.Modified;
                    // context.Entry(foo).State = EntityState.Modified;
                    // context.SaveChanges();
                    //dbContext.SaveChanges();
                }
                //Verification Email
                // VerificationEmail(registrationView.Email, registrationView.ActivationCode.ToString());
                messageRegistration = "Your account has been created successfully.";
                statusRegistration  = true;
            }
            else
            {
                messageRegistration = "Something Wrong!";
            }
            ViewBag.Message = messageRegistration;
            ViewBag.Status  = statusRegistration;
            return(View(registrationView));
        }
Example #2
0
        public ActionResult DeleteConfirmed(int?id)
        {
            try
            {
                tblRegistration tblRegistration = entities.tblRegistrations.Find(id);
                entities.tblRegistrations.Remove(tblRegistration);

                tbllogin tbllogin = entities.tbllogins.Find(id);
                entities.tbllogins.Remove(tbllogin);

                entities.SaveChanges();
                return(RedirectToAction("Deleteview"));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }