Пример #1
0
        public async System.Threading.Tasks.Task DeleteNotificationsAsync(int userId)
        {
            var notifications = await notiRepo.GetAsync(x => x.UserId == userId);

            foreach (var n in notifications)
            {
                await notiRepo.RemoveAsync(n);
            }
        }
Пример #2
0
        public async Task <string> CreateUserImage(ImageDTO Image)
        {
            Image im = (await imageRepo.GetAsync((el) => el.UserId == Image.UserId)).FirstOrDefault();

            if (im != null)
            {
                await imageRepo.RemoveAsync(im);
            }

            if (Image == null)
            {
                return("empty");
            }
            ;
            byte[] fileBytes = null;
            using (var fs1 = Image.Image.OpenReadStream())
                using (var memoryStream = new MemoryStream())
                {
                    await fs1.CopyToAsync(memoryStream);

                    fileBytes = memoryStream.ToArray();
                }
            Image image = new Image();

            image.UserId   = Image.UserId;
            image.FileName = Image.FileName;
            image.Picture  = fileBytes;
            await imageRepo.CreateAsync(image);

            return("done");
        }
Пример #3
0
        public async System.Threading.Tasks.Task DeleteTask(int id)
        {
            var task = await taskRepo.FindByIdAsync(id);

            var comment = await commentRepo.GetAsync(c => c.TaskId == task.Id);

            var history = await historyRepo.GetAsync(h => h.Task.Id == task.Id);

            foreach (var c in comment)
            {
                await commentRepo.RemoveAsync(c);
            }
            foreach (var h in history)
            {
                await historyRepo.RemoveAsync(h);
            }
            await taskRepo.RemoveAsync(task);
        }
Пример #4
0
        public async System.Threading.Tasks.Task DeleteComment(int id)
        {
            var comment = await commentRepo.FindByIdAsync(id);

            await commentRepo.RemoveAsync(comment);
        }