public void UpdateUser(string userId, string firstName, string lastName, string email, string role, string roleEntityValue, string agencyManager ="")
        {
            if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(role) || (role == "AgencyCollector" && string.IsNullOrEmpty(agencyManager.Trim())))
                throw new Exception ("Required fields are not passed");
            string userName = firstName.ToLower() + "." + lastName.ToLower();
            AccountProfile profile;
            try
            {
                if (!string.IsNullOrEmpty(userId))
                {
                    profile = new AccountProfile(UserEntitiesDataFactory.GetUser(Guid.Parse(userId)).UserName);
                    UserEntitiesDataFactory.UpdateUser(userId, email);
                    UserEntitiesDataFactory.UpdateRole(userId, role);
                }
                else
                {
                    if (UserEntitiesDataFactory.IsUserExits(userName))
                    {
                        userName = UserEntitiesDataFactory.GetUsername(userName);
                    }

                    userId = UserEntitiesDataFactory.CreateUserWithRoles(userName, email, role).ToString();
                    profile = new AccountProfile(userName);
                }

                profile.FirstName = firstName;
                profile.LastName = lastName;
                if (!string.IsNullOrEmpty(roleEntityValue))
                    profile.RoleEntityValue = roleEntityValue;

                if (role == "AgencyCollector")
                {
                    IUnitOfWork uo = new UnitOfWork("CCATDBEntities");
                    IRepository<aspnet_Users> repo = uo.Repository<aspnet_Users>();
                    aspnet_Users user = repo.GetById(new Guid(userId));

                    user.ManagerId = new Guid(agencyManager);

                    repo.Update(user);
                    uo.Save();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public BaseAPIController()
 {
     userId = (Guid)Membership.GetUser(System.Web.HttpContext.Current.User.Identity.Name).ProviderUserKey;
     userName = System.Web.HttpContext.Current.User.Identity.Name;
     roleEntityValue = new AccountProfile(UserName).RoleEntityValue;
 }
 public UserModel(Guid userId)
 {
     user = Membership.GetUser(userId);
     profile = new AccountProfile(UserName);
 }
 public UserModel(Guid userId)
 {
     user    = Membership.GetUser(userId);
     profile = new AccountProfile(UserName);
 }