public ActionResult Delete(string ID)
        {
            RolesActionModel model = new RolesActionModel();

            model.ID = ID;
            return(PartialView("_Delete", model));
        }
Beispiel #2
0
        public async Task <JsonResult> Action(RolesActionModel formModel)
        {
            JsonResult json = new JsonResult();

            IdentityResult result = null;

            if (string.IsNullOrEmpty(formModel.Id)) //Create
            {
                var role = new IdentityRole();

                role.Name = formModel.Name;

                result = await RoleManager.CreateAsync(role);
            }
            else //edit
            {
                var role = await RoleManager.FindByIdAsync(formModel.Id);

                role.Name = formModel.Name;

                result = await RoleManager.UpdateAsync(role);
            }

            json.Data = new { success = result.Succeeded, message = string.Join(" , ", result.Errors) };
            return(json);
        }
Beispiel #3
0
        public async Task <JsonResult> Action(RolesActionModel model)
        {
            IdentityResult result = null;
            JsonResult     json   = new JsonResult();

            if (!string.IsNullOrEmpty(model.ID)) // We try to edit record
            {
                var role = await RoleManager.FindByIdAsync(model.ID);

                role.Name = model.Name;


                result = await RoleManager.UpdateAsync(role);
            }
            else // We try to create record
            {
                var role = new IdentityRole();
                role.Name = model.Name;


                result = await RoleManager.CreateAsync(role);
            }
            json.Data = new { Success = result.Succeeded, Message = string.Join(",", result.Errors) };


            return(json);
        }
        public async Task <JsonResult> Action(RolesActionModel role)
        {
            IdentityResult result = null;
            JsonResult     json   = new JsonResult();

            //HMSUser model = new HMSUser();

            if (!string.IsNullOrEmpty(role.ID)) //try to edit records
            {
                var model = await RoleManager.FindByIdAsync(role.ID);

                model.Id   = role.ID;
                model.Name = role.Name;
                result     = await RoleManager.UpdateAsync(model);
            }
            else
            {
                var model = new IdentityRole();
                model.Name = role.Name;
                result     = await RoleManager.CreateAsync(model);
            }

            json.Data = new { Success = result.Succeeded, Message = string.Join(",", result.Errors) };
            return(json);
        }
        public async Task <JsonResult> Delete(RolesActionModel model)
        {
            JsonResult json = new JsonResult();



            IdentityResult result = null;

            if (!string.IsNullOrEmpty(model.ID)) // tyring to delete record
            {
                var role = await RoleManager.FindByIdAsync(model.ID);

                result = await RoleManager.DeleteAsync(role);

                json.Data = new { Success = result.Succeeded, Message = string.Join(",", result.Errors) };
            }
            else
            {
                json.Data = new { Success = false, Message = "Invalid User" };
            }



            return(json);
        }
Beispiel #6
0
        public async Task <ActionResult> Delete(string Id)
        {
            RolesActionModel model = new RolesActionModel();
            var role = await RoleManager.FindByIdAsync(Id);

            model.Id = role.Id;
            return(PartialView("_Delete", model));
        }
        public async Task <ActionResult> Action(string ID)
        {
            RolesActionModel model = new RolesActionModel();

            if (!string.IsNullOrEmpty(ID)) //try to edit records
            {
                var user = await RoleManager.FindByIdAsync(ID);

                model.ID   = user.Id;
                model.Name = user.Name;
            }
            return(PartialView("_Action", model));
        }
Beispiel #8
0
        public async Task <ActionResult> Action(string ID)
        {
            RolesActionModel model = new RolesActionModel();

            if (!string.IsNullOrEmpty(ID))//We are trying to edit a Record
            {
                var role = await RoleManager.FindByIdAsync(ID);

                model.ID   = role.Id;
                model.Name = role.Name;
            }
            return(PartialView("_Action", model));
        }
Beispiel #9
0
        public async Task <ActionResult> Action(string id)
        {
            RolesActionModel model = new RolesActionModel();

            if (!string.IsNullOrEmpty(id)) // edit
            {
                var role = await RoleManager.FindByIdAsync(id);

                model.Id   = role.Id;
                model.Name = role.Name;
            }

            return(PartialView("_Action", model));
        }
Beispiel #10
0
        public async Task <ActionResult> Action(string Id)
        {
            RolesActionModel model = new RolesActionModel();

            if (!string.IsNullOrEmpty(Id))//editing a record
            {
                var role = await RoleManager.FindByIdAsync(Id);

                model.Id   = role.Id;
                model.Name = role.Name;
            }
            // model.AccomodationPackages = accomodationPackageService.GetAllAccomodationPackage();
            return(PartialView("_Action", model));
            //else//creating a new record
            //{

            //}
        }
Beispiel #11
0
        // delete (post)
        public async Task <JsonResult> Delete(RolesActionModel formModel)
        {
            JsonResult json = new JsonResult();

            if (!string.IsNullOrEmpty(formModel.Id))
            {
                var role = await RoleManager.FindByIdAsync(formModel.Id);

                var result = await RoleManager.DeleteAsync(role);

                json.Data = new { success = result.Succeeded, message = string.Join(" , ", result.Errors) };
            }
            else
            {
                json.Data = new { success = false, message = "Invalid user." }
            };

            return(json);
        }
    }
        public async Task <JsonResult> Delete(RolesActionModel model)
        {
            JsonResult     json   = new JsonResult();
            IdentityResult result = null;

            //IdentityRole roles = new IdentityRole();
            //roles.Id = model.ID;

            if (!string.IsNullOrEmpty(model.ID))
            {
                var user = await RoleManager.FindByIdAsync(model.ID);

                result = await RoleManager.DeleteAsync(user);

                json.Data = new { Success = result.Succeeded, Message = string.Join(",", result.Errors) };
            }
            else
            {
                json.Data = new { success = false, Message = "Invalid User" };
            }
            return(json);
        }