예제 #1
0
        /// <summary>
        /// Inserta un usuario nuevo en la base de datos
        /// </summary>
        /// <param name="user">usuario a crear</param>
        /// <param name="session">sesion del usuario</param>
        /// <returns>UserApp</returns>
        public async Task <UserApp> UserAppInsert(UserApp user, UserSession session)
        {
            try
            {
                if (await _userAppData.ExistUserByUserName(user))
                {
                    var control = await _controlsLanguageData.ControlFindByKey("UserExistForName", 2, session.LanguageId);

                    throw control.CreateException(user.UserName);
                }

                user.CreationDate   = DateTime.Now;
                user.UserCreationId = session.Id;
                user.UpdateDate     = null;
                user.UserUpdateId   = null;

                Guid id = await _userAppData.InsertKeyAsync <Guid>(user);

                user.UserId = id;
                return(user);
            }
            catch (Exception)
            {
                throw;
            }
        }