Пример #1
0
        private async Task <AppUser> ApplyUpdate(AppUserDTO user)
        {
            BasicCheck(user ?? throw new ArgumentNullException());
            var appUser = await DbContext.AppUser.SingleOrDefaultAsync(u => u.UserId == user.UserId);

            if (appUser == null)
            {
                throw new BussinessException($"Invalid user id: {user.UserId}");
            }
            _roleCache.GetRoleId(user.Role, out int roleId, out var appRole);
            if (appRole == RoleEnum.CA)
            {
                //CA must have manager
                await CheckUser(user.Manager?.UserId, RoleEnum.BDS, true);
            }
            if (appRole == RoleEnum.BDS)
            {
                //Currenly, only CA allow to have manager
                if (user.Manager != null)
                {
                    throw new BussinessException($"Only CA can have manager(BDS)");
                }
            }
            appUser.Name      = user.Name;
            appUser.Username  = user.Username.ToLower();
            appUser.Hr        = user.HR;
            appUser.Active    = user.Active;
            appUser.ManagerId = user.Manager?.UserId;
            //Currently, not allowing update user's role
            //appUser.Role = user.Role
            appUser.Phone  = user.Phone;
            appUser.Phone2 = user.Phone2;
            return(appUser);
        }
Пример #2
0
        public async Task <OperationDetails> Create(AppUserDTO appUserDto)
        {
            Mapper.Initialize(cfg => cfg.CreateMap <AppUserDTO, AppUser>());

            var appUser = await Database.UserManager.FindByEmailAsync(appUserDto.Email);

            if (appUser != null)
            {
                return(new OperationDetails(false, "Пользователь с таким логином уже существует!", "Email"));
            }

            appUser = Mapper.Map <AppUserDTO, AppUser>(appUserDto);

            var result = await Database.UserManager.CreateAsync(appUser, appUserDto.Password);

            if (!result.Succeeded)
            {
                return(new OperationDetails(false, result.Errors.FirstOrDefault(), ""));
            }

            await Database.UserManager.AddToRoleAsync(appUser.Id, appUserDto.Role.ToString());

            await Database.SaveAsync();

            return(new OperationDetails(true, "Регистрация прошла успешно!", ""));
        }
Пример #3
0
        public bool RegisterUser(AppUserDTO appUser)
        {
            LoginRegisterMVCDbEntities _dbContext = new LoginRegisterMVCDbEntities();

            if (appUser != null && appUser.EmailAddress != null && appUser.Password != null)
            {
                try
                {
                    ApplicationUser tempUser = new ApplicationUser();

                    // Converting AppUserDTO object to ApplicationUser object
                    tempUser.FirstName          = appUser.FirstName;
                    tempUser.LastName           = appUser.LastName;
                    tempUser.EmailAddress       = appUser.EmailAddress;
                    tempUser.ProfilePicture     = appUser.ProfilePicture;
                    tempUser.PasswordHash       = appUser.Password;
                    tempUser.IsActive           = true;
                    tempUser.UserName           = appUser.UserName;
                    tempUser.DateOfRegistration = appUser.DateOfjoin;

                    // inser new entry to the database
                    _dbContext.ApplicationUsers.Add(tempUser);
                    _dbContext.SaveChanges();

                    return(true);
                }
                catch (Exception E)
                {
                    throw;
                }
            }
            return(false);
        }
        public async Task <ActionResult <AppUserDTO> > UpdateProfile([FromBody] AppUserDTO user, int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (user.Id != id)
            {
                return(BadRequest());
            }

            try
            {
                await _userService.UpdateProfileAsync(user);
            }
            catch (Exception ex)
            {
                if (_userService.GetUserProfileAsync(id.ToString()) == null)
                {
                    return(NotFound());
                }
                else
                {
                    return(BadRequest(ex.Message));
                }
            }
            return(NoContent());
        }
Пример #5
0
        public ActionResult Update(Guid id)
        {
            AppUser user = _appUserService.GetByID(id);// getbyıd find ID and set T

            /*
             * public T GetByID(Guid id)
             *   {
             *        return context.Set<T>().Find(id);
             *   }
             */
            // wee need model because context to model.
            AppUserDTO model = new AppUserDTO();

            model.ID               = user.ID;// added user find to id to T goes to user. and user to model.
            model.FirstName        = user.FirstName;
            model.LastName         = user.LastName;
            model.UserName         = user.UserName;
            model.Email            = user.Email;
            model.Address          = user.Address;
            model.PhoneNumber      = user.PhoneNumber;
            model.UserImage        = user.UserImage;
            model.XSmallUserImage  = user.XSmallUserImage;
            model.CruptedUserImage = user.CruptedUserImage;
            model.Role             = user.Role;

            // need return!
            return(View(model));// model= appuser/list page!
        }
Пример #6
0
        public async Task <ActionResult <AppUserDTO> > PostUser([FromBody] NewAppUserDTO userDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var user = new AppUser()
            {
                Id           = userDto.Id,
                FirstName    = userDto.FirstName,
                LastName     = userDto.LastName,
                Presentation = userDto.Presentation,
                Email        = userDto.Email,
                Phone        = userDto.Phone,
                Picture      = userDto.Picture,
            };

            _context.AppUsers.Add(user);
            await _context.SaveChangesAsync();

            var dto = new AppUserDTO(user);

            return(CreatedAtAction("GetUser", new { id = user.Id }, dto));
        }
        public ActionResult UpdateUser(AppUserDTO model)
        {
            if (ModelState.IsValid)
            {
                AppUser user = db.AppUsers

                               .FirstOrDefault(x => x.ID == model.ID);

                user.FirstName = model.FirstName;
                user.LastName  = model.LastName;
                user.Email     = model.Email;
                user.Password  = model.Password;

                user.Status     = DAL.ORM.Enum.Status.Updated;
                user.UpdateDate = DateTime.Now;

                db.SaveChanges();

                return(Redirect("/AppUser/UserList"));
            }

            else
            {
                return(View());
            }
        }
Пример #8
0
 public bool IsInRole(AppUserDTO user, RoleDTO role)
 {
     using (var connection = new SqlConnection(UsersConnectionString))
     {
         var fcommand = connection.CreateCommand();
         var name     = user.Name;
         var Role     = role.Name;
         fcommand.CommandText = "SELECT Username, Role FROM dbo.UsersRoles WHERE dbo.UsersRoles.Username=@name AND dbo.UsersRoles.Role=@role";
         fcommand.Parameters.AddWithValue("@name", name);
         fcommand.Parameters.AddWithValue("@role", Role);
         connection.Open();
         int summary = 0;
         using (SqlDataReader reader = fcommand.ExecuteReader())
         {
             while (reader.Read())
             {
                 summary++;
             }
         }
         if (summary > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Пример #9
0
        public bool RemoveRole(AppUserDTO user, RoleDTO role)
        {
            int summary;

            using (var connection = new SqlConnection(UsersConnectionString))
            {
                var command = connection.CreateCommand();
                command.CommandText = "DELETE FROM dbo.UsersRoles WHERE Username = @userName AND Role =  @roleName ";
                command.Parameters.AddWithValue("@userName", user.Name);
                command.Parameters.AddWithValue("@roleName", role.Name);
                connection.Open();
                summary = command.ExecuteNonQuery();
            }
            if (summary > 0)
            {
                user.Roles.Remove(role);
                return(true);
            }

            else
            {
                DBconnectException e = new DBconnectException("Can't remove role from user");
                LogType.AddLog(e);
                return(false);
            }
        }
Пример #10
0
        public bool AddRole(AppUserDTO user, RoleDTO role)
        {
            int summary;

            using (var connection = new SqlConnection(UsersConnectionString))
            {
                var command = connection.CreateCommand();
                command.CommandText = "INSERT INTO dbo.UsersRoles (Username, Role) VALUES(@userName, @roleName) ";
                command.Parameters.AddWithValue("@userName", user.Name);
                command.Parameters.AddWithValue("@roleName", role.Name);
                connection.Open();
                summary = command.ExecuteNonQuery();
            }
            if (summary > 0)
            {
                user.Roles.Add(role);
                return(true);
            }

            else
            {
                DBconnectException e = new DBconnectException("Can't add role to user");
                LogType.AddLog(e);
                return(false);
            }
        }
Пример #11
0
        public IEnumerable <AppUserDTO> GetAll()
        {
            using (var connection = new SqlConnection(UsersConnectionString))
            {
                var fcommand = connection.CreateCommand();
                var scommand = connection.CreateCommand();
                fcommand.CommandText = "SELECT Username, Password FROM dbo.AppUsers";
                connection.Open();
                AppUserDTO        user  = null;
                List <AppUserDTO> Users = new List <AppUserDTO>();
                using (SqlDataReader reader = fcommand.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var pass = (Byte[])reader["Password"];
                        var name = reader["Username"] as string;
                        user = new AppUserDTO(name, pass);
                        scommand.CommandText = "SELECT Role FROM  dbo.UsersRoles u WHERE  u.Username=@name";
                        scommand.Parameters.AddWithValue("@name", name);
                        using (SqlDataReader new_reader = scommand.ExecuteReader())
                        {
                            while (new_reader.Read())
                            {
                                var roleName = new_reader["Role"] as string;
                                user.Roles.Add(new RoleDTO(roleName));
                            }
                        }
                        Users.Add(user);
                        scommand.Parameters.Clear();
                    }
                }

                return(Users);
            }
        }
Пример #12
0
        public AppUserDTO Get(string name)
        {
            using (var connection = new SqlConnection(UsersConnectionString))
            {
                var fcommand = connection.CreateCommand();
                var scommand = connection.CreateCommand();
                fcommand.CommandText = "SELECT Username, Password FROM dbo.AppUsers WHERE Username= @name ;";
                fcommand.Parameters.AddWithValue("@name", name);
                connection.Open();
                AppUserDTO user = null;
                using (SqlDataReader reader = fcommand.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var pass = (Byte[])reader["Password"];

                        user = new AppUserDTO(name, pass);
                        scommand.CommandText = "SELECT Role FROM  dbo.UsersRoles u WHERE u.Username= @name";
                        scommand.Parameters.AddWithValue("@name", name);
                        using (SqlDataReader new_reader = scommand.ExecuteReader())
                        {
                            while (new_reader.Read())
                            {
                                var roleName = (string)new_reader["Role"];
                                user.Roles.Add(new RoleDTO(roleName));
                            }
                        }
                    }
                }

                return(user);
            }
        }
Пример #13
0
        public ActionResult Update(AppUserDTO model, HttpPostedFileBase Image)
        {
            AppUser       appUser          = _repo.GetById(model.Id);
            List <string> UploadImagePaths = new List <string>();

            UploadImagePaths = ImageUploader.UploadSingleImage(ImageUploader.OriginalProfileImagePath, Image, 1);

            model.UserImage = UploadImagePaths[0];

            if (model.UserImage == "1" || model.UserImage == "2" || model.UserImage == "3")
            {
                if (appUser.UserImage == null || appUser.UserImage == ImageUploader.DefaultProfileImagePath)
                {
                    appUser.UserImage        = ImageUploader.DefaultProfileImagePath;
                    appUser.XSmallUserImage  = ImageUploader.DefaultXSmallProfileImagePath;
                    appUser.CruptedUserImage = ImageUploader.DefaultCruptedProfileImagePath;
                }
            }
            else
            {
                appUser.UserImage        = UploadImagePaths[0];
                appUser.XSmallUserImage  = UploadImagePaths[1];
                appUser.CruptedUserImage = UploadImagePaths[2];
            }

            appUser.FirstName = model.FirstName;
            appUser.LastName  = model.LastName;
            appUser.UserName  = model.UserName;
            appUser.Password  = model.Password;
            appUser.Role      = model.Role;
            _repo.Update(appUser);
            return(Redirect("/Admin/AppUser/List"));
        }
Пример #14
0
 private async Task <AppUser> ToNewUser(AppUserDTO user)
 {
     BasicCheck(user ?? throw new ArgumentNullException());
     //Check role & get role id
     _roleCache.GetRoleId(user.Role, out int roleId, out var appRole);
     //CA must have manager
     if (appRole == RoleEnum.CA)
     {
         //CA must have manager
         await CheckUser(user.Manager?.UserId, RoleEnum.BDS, true);
     }
     if (appRole == RoleEnum.BDS)
     {
         //Currenly, only CA allow to have manager
         if (user.Manager != null)
         {
             throw new BussinessException($"Only CA can have manager(BDS)");
         }
     }
     return(new AppUser()
     {
         Name = user.Name,
         Username = user.Username.ToLower(),
         Active = true,
         Email = $"{user.Username}{_options.Suffix}",
         Hr = user.HR,
         Phone = user.Phone,
         Phone2 = user.Phone2,
         RoleId = roleId,
         ManagerId = user.Manager?.UserId
     });
 }
        public AppUserDTO SaveUser(AppUserDTO dto)
        {
            if (ERSAIDB.Users.Any(u => u.UserName == dto.UserName && u.Id != dto.ID))
            {
                throw new Exception("UserName has to be unique");
            }

            var user = ERSAIDB.Users.Find(dto.ID) ?? ERSAIDB.Users.Add(new AppUser());

            user.FromDTO(dto);

            var results = new List <ValidationResult>();
            var context = new ValidationContext(user);

            if (!Validator.TryValidateObject(user, context, results, true))
            {
                throw new Exception(string.Join(", ", results.Select(er => er.ErrorMessage)));
            }

            user.Id = user.Id ?? Guid.NewGuid().ToString();

            if (dto.NewPassword != null)
            {
                user.PasswordHash  = App.ASPIdentityPasswordHasher.HashPassword(dto.NewPassword);
                user.SecurityStamp = Guid.NewGuid().ToString();
            }

            ERSAIDB.SaveChanges();
            ERSAIDB.Entry(user).Reload();
            dto.FromEF(user);
            return(dto);
        }
Пример #16
0
        public async Task <IActionResult> PostAsync([FromBody] AppUserDTO regDTO)
        {
            try
            {
                var appUser = new AppUser()
                {
                    Email     = regDTO.Email,
                    FirstName = regDTO.FirstName,
                    LastName  = regDTO.LastName,
                    UserName  = regDTO.UserName
                };
                IdentityResult result = await _accountService.CreateAsync(appUser, regDTO.Password);

                if (result.Succeeded)
                {
                    await _accountService.AddToRoleAsync(appUser, Constant.Operation.Admin);

                    return(Ok());
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #17
0
        public ActionResult Update(AppUserDTO data, HttpPostedFileBase Image)
        {
            data.ImagePath = ImageUploader.UploadSingleImage("~/Uploads", Image);

            AppUser user = service.AppUserService.GetById(data.Id);

            if (data.ImagePath == "0" || data.ImagePath == "1" || data.ImagePath == "2")
            {
                if (user.ImagePath == null || user.ImagePath == "~/Content/Images/avantaj.png")
                {
                    data.ImagePath = "~/Content/Images/avantaj.png";
                }
                else
                {
                    data.ImagePath = user.ImagePath;
                }
            }
            user.UserName  = data.UserName;
            user.Password  = data.Password;
            user.Role      = data.Role;
            user.ImagePath = data.ImagePath;
            user.Email     = data.Email;
            service.AppUserService.Update(user);

            return(Redirect("/Admin/AppUser/ListMember"));
        }
        protected void btnAddOrgDebug_Click(object sender, EventArgs e)
        {
            var message       = "";
            var username      = "******";
            var svc           = new MyFileItAppService();
            var appUserObject = new AppUserDTO()
            {
                USERNAME           = username,
                EMAILADDRESS       = username,
                PASSWORD           = "******",
                FIRSTNAME          = "first",
                LASTNAME           = "last",
                ADDRESS1           = "ADDRESS1",
                CITY               = "CITY",
                STATECODE          = "PA",
                ZIPCODE            = "19442",
                SEX                = "M",
                PRIMARYAPPUSERID   = 0,
                APPUSERTYPEID      = 4,
                BIRTHDATE          = null,
                PHONE              = "1234",
                RELATIONSHIPTYPEID = 2,
                DATECREATED        = DateTime.UtcNow,
                APPUSERSTATUSID    = 2
            };

            var response = svc.AddAppUser(SERVICEUSER, SERVICEPASS, appUserObject);

            lblMessage.Text = response.Success.ToString();
        }
Пример #19
0
 public void Delete(AppUserDTO entityDto)
 {
     using (UnitOfWorkProvider.Create())
     {
         appUserService.Delete(entityDto.Id);
     }
 }
Пример #20
0
 public void Update(AppUserDTO entityDto)
 {
     using (UnitOfWorkProvider.Create())
     {
         appUserService.Update(entityDto);
     }
 }
Пример #21
0
 public void AddUserToGroup(AppUserDTO user, GroupDTO group)
 {
     using (UnitOfWorkProvider.Create())
     {
         groupService.AddUserToGroup(user, group);
     }
 }
Пример #22
0
        public async Task <ActionResult <TokenUserDTO> > Login(AppUserDTO userDTO)
        {
            var myUser = await _context.Users.SingleOrDefaultAsync(usr => usr.Username == userDTO.Username);

            if (myUser == null)
            {
                return(Unauthorized("Username does not exist"));
            }
            using var hmac = new HMACSHA512(myUser.PasswordSalt);
            var checkPasswordHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(userDTO.Password));

            for (int i = 0; i < checkPasswordHash.Length; i++)
            {
                if (checkPasswordHash[i] != myUser.PasswordHash[i])
                {
                    return(Unauthorized("Invalid Password"));
                }
            }
            var tokenUser = new TokenUserDTO
            {
                Username = myUser.Username,
                Token    = _tokenService.CreateToken(myUser)
            };

            return(tokenUser);
        }
Пример #23
0
        protected void btnShareKeyUpdate_Click(object sender, EventArgs e)
        {
            MyFileIt.MyFileItAppServiceClient obj    = new MyFileIt.MyFileItAppServiceClient();
            MyFileIt.MyFileItResult           result = new MyFileIt.MyFileItResult();
            FileCabinetDocumentDTO            objf   = new FileCabinetDocumentDTO();
            ShareKeyDTO objKey = new ShareKeyDTO();
            AppUserDTO  user   = new AppUserDTO();

            List <AppUserDTO> objUsers = new List <AppUserDTO>();

            result = obj.GetAppUsers(appGlobal.username, appGlobal.password, 2, "");
            user   = result.AppUsers.First();
            user.SHAREKEYEXPIREDATE = DateTime.Now.AddDays(365);
            result = obj.UpdateAppUser(appGlobal.username, appGlobal.password, user);

            objKey.ID               = 10;
            objKey.APPUSERID        = null;
            objKey.AMOUNT           = Convert.ToDecimal("3.99");
            objKey.DATECREATED      = DateTime.Now;
            objKey.LAST4CC          = "0002";
            objKey.PAYMENTTYPEID    = 1;
            objKey.PRIMARYAPPUSERID = user.ID;
            objKey.PROMOCODE        = "";
            objKey.PURCHASEDATE     = DateTime.Now;
            objKey.SALESREPID       = 1;
            objKey.SHAREKEYCODE     = "20151022-0001";
            objKey.ApplicationUser  = user;
            result = obj.UpdateShareKey(appGlobal.username, appGlobal.password, objKey);
        }
Пример #24
0
        private void aftabTest()
        {
            MyFileIt.MyFileItAppServiceClient obj    = new MyFileIt.MyFileItAppServiceClient();
            MyFileIt.MyFileItResult           result = new MyFileIt.MyFileItResult();
            var message = "";

            int        appUserIDLookup   = 3;
            int        newOrganizationID = 12;
            int        oldOrganizationID = 10;
            DateTime   startDate         = DateTime.Now;
            DateTime   expiresDate       = DateTime.Now.AddDays(10);
            int        yearCode          = 2015;
            int        sportTypeID       = 2;
            int        appUserTypeId     = 5;
            AppUserDTO user = null;

            result = obj.GetAppUsers(appGlobal.username, appGlobal.password, appUserIDLookup, null);
            user   = result.AppUsers.First();

            user.Organizations.Where(o => o.ID == oldOrganizationID || o.ID == newOrganizationID).ToList().ForEach(o =>
            {
                obj.RemoveAppUserFromOrganization(appGlobal.username, appGlobal.password, user.ID, o.ID);
            });

            //  add the new organization link into the table
            result  = obj.AssociateAppUserToOrganization(appGlobal.username, appGlobal.password, user.ID, appUserTypeId, newOrganizationID, startDate, expiresDate, yearCode, sportTypeID);
            message = result.Success ? "Worked" : "Failed";
        }
Пример #25
0
        protected void btnAddRemoveOrganization_Click(object sender, EventArgs e)
        {
            MyFileIt.MyFileItAppServiceClient svc    = new MyFileIt.MyFileItAppServiceClient();
            MyFileIt.MyFileItResult           result = new MyFileIt.MyFileItResult();

            //get all the associations for the user
            int        appUserIDLookup   = 5; //this id is valid on my LOCAL DB, NOT server
            int        newOrganizationID = 25;
            int        oldOrganizationID = 21;
            DateTime   startDate         = DateTime.Now;
            DateTime   expiresDate       = DateTime.Now.AddDays(10);
            int        yearCode          = 2015;
            int        sportTypeID       = 2;
            int        appUserTypeID     = 5;
            AppUserDTO user = null;

            result = svc.GetAppUsers(appGlobal.username, appGlobal.password, appUserIDLookup, null);
            user   = result.AppUsers.First();

            //loop all associated organization and remove specific organization
            //NOTE: I skipped all success / fail catch logic just to run the routine
            user.Organizations.Where(o => o.ID == oldOrganizationID || o.ID == newOrganizationID).ToList().ForEach(o =>
            {
                svc.RemoveAppUserFromOrganization(appGlobal.username, appGlobal.password, user.ID, o.ID);
            });

            //add the new organization link into the table
            result          = svc.AssociateAppUserToOrganization(appGlobal.username, appGlobal.password, user.ID, appUserTypeID, newOrganizationID, startDate, expiresDate, yearCode, sportTypeID);
            lblMessage.Text = result.Success ? "Worked" : "Failed";
        }
Пример #26
0
        public async Task <IActionResult> Register([FromBody] AppUserDTO userDTO)
        {
            var location = GetControllerActionNames();

            try
            {
                var username = userDTO.Email;
                var password = userDTO.Password;
                _logger.LogInfo($"{location}: Registration attempt for {username}");
                var user = new IdentityUser {
                    Email = username, UserName = username
                };
                var result = await _userManager.CreateAsync(user, password);

                if (!result.Succeeded)
                {
                    foreach (var error in result.Errors)
                    {
                        _logger.LogError($"{location}: {error.Code} {error.Description}");
                    }
                    return(InternalError($"{location}: {username} User Registration Attempt Failed"));
                }
                return(Ok(new { result.Succeeded }));
            }
            catch (Exception e)
            {
                return(InternalError($"location:{ e.Message} - {e.InnerException}"));
            }
        }
Пример #27
0
        public async Task <IActionResult> Register([FromBody] AppUserDTO userDto)
        {
            var user = new AppUser {
                UserName = userDto.Username
            };
            var registrationResult = await _userManager.CreateAsync(user, userDto.Password);

            return(registrationResult.Succeeded ? Ok() : (IActionResult)BadRequest(registrationResult.Errors));
        }
Пример #28
0
        public int Create(AppUserDTO entityDto)
        {
            int returnValue;

            using (UnitOfWorkProvider.Create())
            {
                returnValue = appUserService.Create(entityDto);
            }
            return(returnValue);
        }
Пример #29
0
        public async Task <Result> RemoveFromRoleAsync(AppUserDTO appUserDTO, string roleName)
        {
            if (appUserDTO != null && appUserDTO != default && !string.IsNullOrEmpty(roleName))
            {
                var result = await _userManager.RemoveFromRoleAsync(_mapper.Map <AppUser>(appUserDTO), roleName);

                return(result.Succeeded ? Result.Success() : result.ToApplicationResult());
            }
            return(Result.Failure(new string[] { "Некорректные входные данные" }));
        }
Пример #30
0
        public void SubscribeToEvent(EventDTO event_, AppUserDTO subscribingUser)
        {
            AppUser repUser  = Mapper.Map <AppUserDTO, AppUser>(subscribingUser);
            Event   repEvent = Mapper.Map <EventDTO, Event>(event_);

            repUser.EventsAttended.Add(repEvent);
            repEvent.Guests.Add(repUser);
            Repository.Update(repEvent);
            _userRepository.Update(repUser);
        }