public ActionResult Edit(AdminUserManagementModel.CreateAdminAspUser model, Guid id, int[] ChkProductId, FormCollection fc)
        {
            model.UserId = id;
            MembershipUser user;

            user = Membership.GetUser(model.UserId);
            //user.Email =model.GetUserName.aspnet_Membership.Email ;
            Membership.UpdateUser(user);
            ser.UpdateEmail(model);
            ser.EditUserInfo(model);
            var           UserInfo = ser.GetUserDetails(id);
            List <string> roleList = pro.RetrieveAllUserRoles(model.UserId);

            // firstly delete all roles in user
            if (roleList.Count() != 0)
            {
                Roles.RemoveUserFromRoles(model.GetUserName.UserName, roleList.ToArray());
            }
            foreach (int pid in ChkProductId)
            {
                // check if current product exist for current user or not
                pro.CheckExistanceofUserProduct(UserInfo.AppUserId, pid);
                /////////  Save individual User Roles in database ////
                model.AgentRole = fc["RoleId"] ?? fc["RoleId" + pid];
                Roles.AddUserToRole(model.GetUserName.UserName, model.AgentRole);
            }


            return(RedirectToAction("Index"));
        }
Example #2
0
        public void UpdateEmail(AdminUserManagementModel.CreateAdminAspUser model)
        {
            aspnet_Membership tu = db.aspnet_Membership.Where(u => u.UserId == model.UserId).FirstOrDefault();

            tu.UserId       = model.UserId;
            tu.Email        = model.GetEmail.Email;
            tu.LoweredEmail = model.GetEmail.Email;
            db.ApplyCurrentValues(tu.EntityKey.EntitySetName, tu);
            db.SaveChanges();
            /////
        }
Example #3
0
        public void EditRoleInfo(AdminUserManagementModel.CreateAdminAspUser model)
        {
            Core_ProductRoles result = db.Core_ProductRoles.Where(x => x.RoleId == model.RoleId).FirstOrDefault();

            result.RoleId       = model.RoleId;
            result.ProductId    = model.ProductId;
            result.SubProductId = 1;

            db.ApplyCurrentValues(result.EntityKey.EntitySetName, result);
            db.SaveChanges();
        }
        public void CreateUserInProduct(AdminUserManagementModel.CreateAdminAspUser model)
        {
            Core_UserProducts obj = new Core_UserProducts
            {
                ProductId = model.ProductId,
                UserId    = model.UserAppId,
            };

            ent.AddToCore_UserProducts(obj);
            ent.SaveChanges();
        }
        //
        // GET: /AdminUserManagement/
        public ActionResult Create()
        {
            var viewmodel = new AdminUserManagementModel.CreateAdminAspUser
            {
                ProductBaseRoleList = pro.GetProductList(),
                RoleList            = pro.GetAllRolesList(),
            };

            ViewData["RoleAssign"] = new SelectList("", "RoleName", "RoleName", "");
            return(View(viewmodel));
        }
Example #6
0
        public void EditUserInfo(AdminUserManagementModel.CreateAdminAspUser model)
        {
            UsersDetails result = db.UsersDetails.Where(x => x.UserId == model.UserId).FirstOrDefault();


            result.UserTypeId = (model.IsSalesMarketingUser != true ? ((int)ATLTravelPortal.Helpers.UserTypes.BackofficeUser) : ((int)ATLTravelPortal.Helpers.UserTypes.MEs));

            result.UserAddress  = model.UserInfo.UserAddress;
            result.PhoneNumber  = model.UserInfo.PhoneNumber;
            result.MobileNumber = model.UserInfo.MobileNumber;
            result.FullName     = model.UserInfo.FullName;

            db.ApplyCurrentValues(result.EntityKey.EntitySetName, result);
            db.SaveChanges();
        }
        public List <AdminUserManagementModel.CreateAdminAspUser> ListGetUserRoles(Guid?id)
        {
            var result = ent.Core_GetUserRoles(id);
            List <AdminUserManagementModel.CreateAdminAspUser> model = new List <AdminUserManagementModel.CreateAdminAspUser>();

            foreach (var item in result)
            {
                AdminUserManagementModel.CreateAdminAspUser obj = new AdminUserManagementModel.CreateAdminAspUser();

                obj.RolesName = item.RoleName;
                obj.RolesOn   = item.RoleOn;

                model.Add(obj);
            }
            return(model);
        }
        public ActionResult Edit(Guid id)
        {
            RoleBasedRoleModel model = new RoleBasedRoleModel();


            var viewmodel = new AdminUserManagementModel.CreateAdminAspUser
            {
                UserInfo            = ser.GetUserDetails(id),
                GetUserName         = ser.GetUserinfo(id),
                GetEmail            = ser.GetEmail(id),
                ProductBaseRoleList = pro.GetUserAssociatedRolewithProduct(id),
                AdminProductList    = pro.GetProductListId(1),
                //RoleList = pro.GetAllRolesList(),
            };

            viewmodel.IsSalesMarketingUser = viewmodel.UserInfo.UserTypeId != (int)ATLTravelPortal.Helpers.UserTypes.User ? true : false;

            //List<RoleBasedRoleModel> UserAssignRoleList= pro.GetUserAssociatedRolewithProduct(id);
            foreach (var AsociatedProductOfUser in viewmodel.ProductBaseRoleList)
            {
                ViewData[AsociatedProductOfUser.ProductName] = new SelectList(pro.GetAllRolesListonProductWiseForAdminUser(AsociatedProductOfUser.ProductId), "RoleName", "RoleName", AsociatedProductOfUser.RoleName);
            }
            return(View(viewmodel));
        }
 public void CreateUser(AdminUserManagementModel.CreateAdminAspUser obj)
 {
     ent.CreateASPUser(obj.UserName, obj.Password, obj.Email, "ADMIN", null, obj.FullName, obj.Address, obj.MobileNo, obj.PhoneNo, (obj.IsSalesMarketingUser != true ? ((int)ATLTravelPortal.Helpers.UserTypes.BackofficeUser) : ((int)ATLTravelPortal.Helpers.UserTypes.MEs)), obj.CreatedBy, "Holidays");
 }
        public ActionResult Create(AdminUserManagementModel.CreateAdminAspUser model, int[] ChkProductId, FormCollection fc)
        {
            TravelSession obj = (TravelSession)Session["TravelPortalSessionInfo"];

            model.CreatedBy = obj.AppUserId;
            if (ChkProductId == null)
            {
                //// Validate to Choose atleast one product //////////
                TempData["ErrorMessage"] = "Please Choose Atleast one Product.";
                ViewData["RoleAssign"]   = new SelectList("", "RoleName", "RoleName", "");
                var viewmodel = new AdminUserManagementModel.CreateAdminAspUser
                {
                    ProductBaseRoleList = pro.GetProductList(),
                    RoleList            = pro.GetAllRolesList(),
                };
                return(RedirectToAction("Create", viewmodel));
            }
            if (model.Password != model.ConfirmPassword || model.UserName == "")
            {
                TempData["ErrorMessage"] = "Registration failed! Either Enter Username or Your passwords must match, please re-enter and try again";
                ViewData["RoleAssign"]   = new SelectList("", "RoleName", "RoleName", "");
                var viewmodel = new AdminUserManagementModel.CreateAdminAspUser
                {
                    ProductBaseRoleList = pro.GetProductList(),
                    RoleList            = pro.GetAllRolesList(),
                };
                return(RedirectToAction("Create", viewmodel));
            }
            ///////////////////////////////////////////////////////////////////////////////////////////////
            // ************ Save User membership in database ************************************************
            //////////////////////////////////////////////////////////////////////////////////////////////////
            pro.CreateUser(model);
            int AppuserId = pro.GetLastAppUserId().ToList().Last().AppUserId;  ////Get UserId

            model.UserAppId = AppuserId;

            Guid UserId = pro.GetLastAppUserId().ToList().Last().UserId; ////Get UserId

            pro.UpdateAspnet_Membership(UserId);
            //////// Collecting Product and corresponding Role ///////////////
            List <int> ProductIds = new List <int>();

            ProductIds = new List <int>();
            foreach (int cid in ChkProductId)
            {
                ProductIds.Add(cid);
                model.ProductId = cid;
                pro.CreateUserInProduct(model);
            }
            //////////////collect Agent Associate Product and save /////////////////////////////////////////////////////////////
            List <int> ChkProductIdS = new List <int>();

            foreach (int pid in ChkProductId)
            {
                ChkProductIdS.Add(pid);
                /////////  Save individual User Roles in database ////
                model.AgentRole = fc["RoleId"] ?? fc["RoleId" + pid];

                Roles.AddUserToRole(model.UserName, model.AgentRole);
            }


            //// If success Return Back to list
            return(RedirectToAction("Index"));
        }