public async Task <JsonResult> MarkToStarred(int msgId, bool isStarred) { bool success; if (isStarred) { success = await _messageRepository.MarkAsStarred(SiteUser.UserId, new[] { msgId }); } else { var updatedMessage = await _messageRepository.UpdateMessageStatus(SiteUser.UserId, msgId, (int)MessageStatus.Default); success = updatedMessage.Status == (int)MessageStatus.Default; } var newCategories = await GetCategoriesByMessageStatus(SiteUser.UserId, "starred"); var jsCategories = newCategories?.Select(cat => new { id = cat.Categoryid, name = cat.CategoryName, isSelected = false }); return(Json(new { success = success, categories = jsCategories })); }