public IHttpActionResult GetBlockedUserListByUserId(RequestModel model) { List <UserBlockWithAllInfo> blockedUserList = new List <UserBlockWithAllInfo>(); try { if (string.IsNullOrEmpty(model.Id)) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "User Id is required."))); } long userId = Convert.ToInt64(model.Id); blockedUserList = _blockservice.GetBlockedUserListByUserId(userId).ToList(); foreach (var item in blockedUserList) { if (string.IsNullOrEmpty(item.ImagePath)) { item.ImagePath = noImagePath; } else { var extension = item.ImagePath.Split('.')[1]; var imageName = item.ImagePath.Split('.')[0] + "_thumbnail"; item.ImagePath = proImagePath + imageName + "." + extension; } //item.ImagePath = item.ImagePath == null ? noImagePath : item.ImagePath == string.Empty ? noImagePath : proImagePath + item.ImagePath; item.Flag_Icon = item.Flag_Icon == null ? noImagePath : item.Flag_Icon == string.Empty ? noImagePath : imagePath + item.Flag_Icon; } } catch (Exception e) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message))); } return(Ok(blockedUserList)); }
public IHttpActionResult GetAllUserWithCountryIcon(RequestModel model) { IList <UserWithCountryIconInfo> obj = new List <UserWithCountryIconInfo>(); try { if (string.IsNullOrEmpty(model.Id)) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "User Id is required."))); } long userID = Convert.ToInt64(model.Id); var userList = _UserService.GetAllUsersWithCountryFlag(); foreach (var item in userList) { bool isAdd = false; var blockList = _blockService.GetBlockedUserListByUserId(userID).ToList(); if (blockList.Count > 0) { var blockDetails = blockList.Where(a => a.BlockedUserId == item.User_Id).FirstOrDefault(); if (blockDetails == null) { isAdd = true; } } else { blockList = _blockService.GetBlockedUserListByUserId(item.User_Id).ToList(); if (blockList.Count > 0) { var blockDetails = blockList.Where(a => a.BlockedUserId == userID).FirstOrDefault(); if (blockDetails == null) { isAdd = true; } } else { isAdd = true; } } if (isAdd) { UserWithCountryIconInfo details = new UserWithCountryIconInfo(); details.Address = item.Address; details.Country_Id = item.Country_Id; details.CreatedTime = item.CreatedTime; details.DeviceId = item.DeviceId; details.Dob = item.Dob; details.Email_Id = item.Email_Id; details.Flag_Icon = item.Flag_Icon; details.Gender = item.Gender; details.Icon_Path = imagePath + item.Flag_Icon; if (string.IsNullOrEmpty(item.ImagePath)) { details.ImagePath = noImagePath; } else { var extension = item.ImagePath.Split('.')[1]; var imageName = item.ImagePath.Split('.')[0] + "_thumbnail"; details.ImagePath = proImagePath + imageName + "." + extension; } //details.ImagePath = item.ImagePath == null ? noImagePath: item.ImagePath == string.Empty ? noImagePath: proImagePath + item.ImagePath; details.Interests = item.Interests; details.IsVerified = item.IsVerified; details.LagLevel_ID = item.LagLevel_ID; details.Name = item.Name; details.QR_Code = item.QR_Code; details.Self_Introduction = item.Self_Introduction; details.TravelDestination_CId = item.TravelDestination_CId; details.TrevoId = item.TrevoId; details.User_Id = item.User_Id; var languageDetails = _languageService.GetLanguageDetailsById(item.Native_LanguageId); if (languageDetails != null) { details.NativeAbbrv = languageDetails.Abbreviation; } languageDetails = _languageService.GetLanguageDetailsById(item.Learning_LanguageId); if (languageDetails != null) { details.LearningAbbrv = languageDetails.Abbreviation; } obj.Add(details); } } } catch (Exception e) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message))); } return(Ok(obj)); }