Ejemplo n.º 1
0
        public ActionResult AddEmployee(Employee employee,FormCollection col)
        {
            Employee emp = new Employee();
            emp.TeamID = Convert.ToInt32(col["EmployeeTeam"]);
            emp.EmployeeRole = col["roles"];
            emp.EmployeeContact = employee.EmployeeContact;
            employeeRepository.InsertOrUpdate(emp);
            employeeRepository.Save();
            string[] roles= {emp.EmployeeRole};
            string[] username = {employee.EmployeeContact.ContactEmail};
            MembershipCreateStatus createStatus;
            CodeFirstMembershipProvider provider = new CodeFirstMembershipProvider();
            provider.CreateAccount(username[0], "KStart123", employee.EmployeeContact.ContactEmail,out createStatus);
            CodeFirstRoleProvider roleProvider = new CodeFirstRoleProvider();
            roleProvider.AddUsersToRoles(username, roles);

            return View();
        }
Ejemplo n.º 2
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 });
        }