Esempio n. 1
0
        public async Task AddAsync(ExpertRequest request)
        {
            var user = await _userRepository.GetByAddressAsync(request.Address);

            if (user == null)
            {
                throw new AppErrorException(ErrorCode.UserNotFound);
            }

            user.SecondName = request.SecondName;
            user.FirstName  = request.FirstName;
            user.Email      = request.Email;
            user.About      = request.About;

            await _userRepository.AddRoleAsync(user.Id, RoleType.Expert);

            await _userRepository.SaveChangesAsync();

            var expert = new Expert(user.Id, true);

            expert.SetAreas(request.Areas);

            _expertRepository.Add(expert);

            await _expertRepository.SaveChangesAsync();
        }
Esempio n. 2
0
        public async Task <IActionResult> CreateExpertAsync([FromBody] ExpertRequest request)
        {
            await _ethereumClient.WaitForConfirmationAsync(request.TransactionHash);

            await _expertService.AddAsync(request);

            return(NoContent());
        }
Esempio n. 3
0
        /// <summary>
        /// Decline the expert request and do nothing with the user contained in the request.
        ///
        /// Created By: Trent Cullinan 03/15/2016
        /// </summary>
        /// <param name="request">ExpertRequest to be declined.</param>
        /// <returns>Rows affected by action.</returns>
        ///
        /// TRex changed method name from DeclineRequest to UpdateExpertRequestDecline on 4/11/16
        public int UpdateExpertRequestDecline(ExpertRequest request)
        {
            int rowsAffected = 0;

            var conn = DBConnection.GetDBConnection();

            var cmd = new SqlCommand("Admin.spUpdateExpertRequestDecline", conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@requestID",
                                        request.RequestID);
            cmd.Parameters.AddWithValue("@userID",
                                        request.User.UserID);
            cmd.Parameters.AddWithValue("@modifiedby",
                                        accessToken.UserID);
            //request.User.UserID);
            cmd.Parameters.AddWithValue("@approved",
                                        0);


            try
            {
                conn.Open();

                rowsAffected = cmd.ExecuteNonQuery();
            }
            catch (SqlException)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return(rowsAffected);
        }
        /// <summary>
        /// Decline the expert request and do nothing with the user contained in the request.
        ///
        /// Created By: Trent Cullinan 03/15/2016
        /// </summary>
        /// <param name="accessToken">To confirm access as administrator.</param>
        /// <param name="request">ExpertRequest to be declined.</param>
        /// <returns>Whether the action was successful.</returns>
        public bool AddRequestDeclined(AccessToken accessToken, ExpertRequest request)
        {
            bool flag = false;

            if (GetAdminRoleStatus(accessToken))
            {
                try
                {
                    flag = 1 == adminExpertRequestsAccessor.UpdateExpertRequestDecline(request); // 1 record should be affected.

                    if (flag)
                    {
                        RemoveRequest(request);
                    }
                }
                catch (SqlException ex)
                {
                    throw new Exception(ex.Message);
                }
            }

            return(flag);
        }
        /// <summary>
        /// Approve the expert request and set user contained in request as an expert.
        ///
        /// Created By: Trent Cullinan 03/15/2016
        /// </summary>
        /// <param name="accessToken">To confirm access as administrator.</param>
        /// <param name="request">ExpertRequest to be declined.</param>
        /// <returns>Whether the action was successful.</returns>
        public bool AddRequestApproved(AccessToken accessToken, ExpertRequest request)
        {
            bool flag = false;


            try
            {
                flag = 2 == adminExpertRequestsAccessor.UpdateExpertRequestApprove(request);     // 2 records should be affected.

                if (flag)
                {
                    RemoveRequest(request);
                }
            }
            catch (SqlException ex)
            {
                //throw new Exception("Error with database, try again later.");
                throw new Exception(ex.Message);
            }


            return(flag);
        }
 // Created By: Trent Cullinan 03/15/2016
 private void RemoveRequest(ExpertRequest request)
 {
     this.requests.Remove(this.requests.Single(r => r.RequestID == request.RequestID));
 }