public async Task <OperationStatus <T> > CreateAsync <T>(T item) { var dto = item as RoleDto; var result = await _roleManager.CreateAsync(new IdentityRole <Guid>(dto.Name)); if (!result.Succeeded) { _operationHelper.InternalServerError <T>(_errorHelper.ErrorMessage(result)); } await _context.SaveChangesAsync(); return(_operationHelper.OK <T>("Role created successfully")); }
public async Task <OperationStatus <T> > CreateAsync <T>(T dto) { var user = _mapper.Map <User>(dto); user.UserName = user.Email; var result = await _userManager.CreateAsync(user, _defaultPass); if (!result.Succeeded) { _operationHelper.InternalServerError <T>(_errorHelper.ErrorMessage(result)); } await _context.SaveChangesAsync(); return(_operationHelper.OK <T>("User created successfully")); }
public async Task <OperationStatus <T> > CreateAsync <T>(T item) { if (!(item is EmployeeDto dto)) { return(_operationHelper.BadRequest <T>("EmployeeDto is null")); } var employee = await _userManager.FindByIdAsync(dto.EmployeeId.ToString()); employee.ManagerId = dto.UserId; var result = await _userManager.UpdateAsync(employee); if (!result.Succeeded) { _operationHelper.InternalServerError <T>(_errorHelper.ErrorMessage(result)); } await _context.SaveChangesAsync(); return(_operationHelper.OK <T>("Employee added successfully")); }