public IActionResult GetById(int id, int loggedInId) { var user = userService.GetById(id); var userCategories = categoryService.GetAllCategoriesForUser(id); var categories = categoryService.GetAllCategories(); var userCategoryModels = userCategories.Select(result => new CategoryViewModel { CategoryId = result.CategoryId, CategoryName = categories.SingleOrDefault(c => c.CategoryId == result.CategoryId).CategoryName, ImageSource = categories.SingleOrDefault(c => c.CategoryId == result.CategoryId).ImageSource }); if (user == null) { return(BadRequest(new { message = "Could not retrieve profile for user." })); } var isFriend = friendService.IsFriend(loggedInId, id); return(Ok(new { Id = user.UserId, FirstName = user.FirstName, LastName = user.LastName, FullName = user.FirstName + " " + user.LastName, Gender = user.Gender, Age = userService.CalculateUserAge(user.BirthDate), State = user.State, Bio = user.Bio, Categories = userCategoryModels.ToList().OrderBy(ucm => ucm.CategoryName), isFriend = isFriend, image = userImageService.GetById(id) })); }
public IActionResult GetById(int id) { var result = _userImageService.GetById(id); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public IActionResult Update([FromForm(Name = "Image")] IFormFile file, [FromForm(Name = ("Id"))] int Id) { var userImages = _userImageService.GetById(Id).Data; var result = _userImageService.Update(file, userImages); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public IActionResult Add([FromForm(Name = ("id"))] int id) { var userImage = _userImageService.GetById(id).Data; var result = _userImageService.Delete(userImage); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }