예제 #1
0
        public async Task <JsonResult> MoveToTrash(string msgIds)
        {
            var messages   = msgIds.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            var messageIds = new List <int>();

            foreach (var msg in messages)
            {
                int outId;
                if (int.TryParse(msg, out outId))
                {
                    messageIds.Add(outId);
                }
            }
            var result = await _messageRepository.MoveToTrash(SiteUser.UserId, messageIds.ToArray());

            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 = result, categories = jsCategories }));
        }