Exemple #1
0
        public bool InsertBlockDetails(UserBlockDetails details)
        {
            List <SqlParameter> sp = new List <SqlParameter>()
            {
                new SqlParameter()
                {
                    ParameterName = "@blockingUserId", Value = details.BlockingUserId, SqlDbType = SqlDbType.BigInt
                },
                new SqlParameter()
                {
                    ParameterName = "@blockedUserId", Value = details.BlockedUserId, SqlDbType = SqlDbType.BigInt
                },
                new SqlParameter()
                {
                    ParameterName = "@blockingTime", Value = details.BlockingTime, SqlDbType = SqlDbType.VarChar
                },
            };

            object[] parameters = sp.ToArray();
            var      users      = _blockRepository.ExecuteStoredProcedureList <AuthUser>(PROC_INSERT_BLOCK_DETAILS, parameters);

            if (users != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        public IHttpActionResult InsertBlockDetails(RequestModel model)
        {
            try
            {
                if (string.IsNullOrEmpty(model.Id) || (string.IsNullOrEmpty(model.ScheduleId)))
                {
                    return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Blocking User Id and Blocked User Id are required.")));
                }

                UserBlockDetails details = new UserBlockDetails();
                details.BlockedUserId  = Convert.ToInt64(model.ScheduleId);
                details.BlockingUserId = Convert.ToInt64(model.Id);

                UserFollowerDetails userFollowDetails = new UserFollowerDetails();
                var userFollowList = _userFollowService.GetAllUserFollowList().Where(a => a.FollowerUserId == details.BlockedUserId && a.FollowingUserId == details.BlockingUserId).ToList();
                foreach (var item in userFollowList)
                {
                    _userFollowService.RemoveUserFollowDetailsByUserId(item.FollowerUserId, item.FollowingUserId);
                }
                userFollowList = _userFollowService.GetAllUserFollowList().Where(a => a.FollowerUserId == details.BlockingUserId && a.FollowingUserId == details.BlockedUserId).ToList();
                foreach (var item in userFollowList)
                {
                    _userFollowService.RemoveUserFollowDetailsByUserId(item.FollowerUserId, item.FollowingUserId);
                }
                var dateTime = DateTime.UtcNow;
                details.BlockingTime = dateTime.ToString(@"yyyy/MM/dd hh:mm tt", new CultureInfo("en-US"));
                _blockservice.InsertBlockDetails(details);
            }
            catch (Exception e)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message)));
            }

            return(Ok("Block details inserted successfully."));
        }