Exemplo n.º 1
0
        public async Task <ActionResult> UserRolesControl(AspNetUserDto value)
        {
            ViewData["SelectedListForRoles"] = new SelectedListHelpers().GetSelectedList(_iAspNetRole.GetAspNetRoles());
            ViewData["UserId"] = value.Id;

            return(View(await _iAspNetUserRoles.Get(new AspNetUserRolesDto {
                UserId = value.Id
            })));
        }
Exemplo n.º 2
0
        public async Task <bool> Delete(AspNetUserDto aspNetUserDto)
        {
            try
            {
                DataAccess.Models.AspNetUser value = Mapper.Map <DataAccess.Models.AspNetUser>(aspNetUserDto);

                db.Entry(value).State = EntityState.Deleted;

                await db.SaveChangesAsync();

                return(true);
            }
            catch { return(false); }
        }
Exemplo n.º 3
0
        public ResponseModel GetAdminUser(ApplicationUser result)
        {
            var roleId = _db3.AspNetUserRoles.FirstOrDefault(o => o.UserId == result.Id);
            var role   = _db2.AspNetRoles.FirstOrDefault(o => o.Id == roleId.RoleId);

            var res = new AspNetUserDto()
            {
                Address       = result.Address,
                DateOfBirth   = result.DateOfBirth.ToString(),
                Email         = result.Email,
                FirstName     = result.FirstName,
                Id            = result.Id,
                LastName      = result.LastName,
                MiddleName    = result.MiddleName,
                PhoneNumber   = result.PhoneNumber,
                PlaceOfBirth  = result.PlaceOfBirth,
                StateOfOrigin = result.StateOfOrigin,
                Role          = role.Name
            };

            if (result.Sex == SexType.Male)
            {
                res.Sex = "Male";
            }
            else
            {
                res.Sex = "Female";
            }

            if (result.UserType == UserType.Admin)
            {
                res.UserType = "Admin";
            }
            else if (result.UserType == UserType.Employee)
            {
                res.UserType = "Employee";
            }
            else
            {
                res.UserType = "Employer";
            }

            var response = new ResponseModel()
            {
                Data = res
            };

            return(response);
        }
Exemplo n.º 4
0
 public async Task <ActionResult> Delete(AspNetUserDto value)
 {
     try
     {
         if (ModelState.IsValid)
         {
             await _iAspNetUser.Delete(value);
         }
     }
     catch
     {
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return(View("AdministrationUsers", _iAspNetUser.GetAspNetUsers()));
 }