Exemplo n.º 1
0
        public ActionResult ClientRegister(ClientRegister form)
        {
            ClientRegister details = new ClientRegister();
            details = form;
            int enqID = Convert.ToInt32(TempData["EnquiryIdClient"]);
            //RegisterModel regMod = new RegisterModel();
            //AccountController accController = new AccountController();
            Enquiry enq = new Enquiry();
            enq = enquiryRepository.Find(enqID);
            //regMod.UserName = enq.Contact.ContactEmail;
            string Password = PasswordGeneration(enq.Contact.ContactName, enq.Contact.MobileNumber);
            //regMod.Email = enq.Contact.ContactEmail;
            //accController.Register(regMod);
            MembershipCreateStatus createStatus;
            CodeFirstMembershipProvider provider = new CodeFirstMembershipProvider();
            provider.CreateAccount(enq.Contact.ContactEmail, Password, enq.Contact.ContactEmail, out createStatus);
            CodeFirstRoleProvider roleProvider = new CodeFirstRoleProvider();
            if (createStatus == MembershipCreateStatus.Success)
            {
                if (!roleProvider.RoleExists("Client"))
                {
                    roleProvider.CreateRole("Client");
                }

                string[] roles = { "Client" };
                string[] users = {enq.Contact.ContactEmail.ToString()};
                roleProvider.AddUsersToRoles(users, roles);

            }
            details.EnquiryID = Convert.ToInt32(TempData["EnquiryIdClient"]);
            details.ContactID = enq.ContactID; // Please see this--Pankaj
            clientRegisterRepository.InsertOrUpdate(details);
            clientRegisterRepository.Save();
            return RedirectToAction("Details", new { id = details.EnquiryID });
        }
 public void InsertOrUpdate(ClientRegister clientregister)
 {
     if (clientregister.ClientID == default(int)) {
         // New entity
         context.ClientRegister.Add(clientregister);
     } else {
         // Existing entity
         context.Entry(clientregister).State = EntityState.Modified;
     }
 }
Exemplo n.º 3
0
 public void InsertOrUpdate(ClientRegister clientregister)
 {
     if (clientregister.ClientID == default(int))
     {
         // New entity
         context.ClientRegister.Add(clientregister);
     }
     else
     {
         // Existing entity
         context.Entry(clientregister).State = EntityState.Modified;
     }
 }