コード例 #1
0
        public async Task DeleteSoundAsync(SoundDTO soundDTO)
        {
            if (soundDTO == null)
            {
                throw new ValidationException("Sound is null!", "");
            }
            await Database.Sounds.DeleteAsync(soundDTO.id);

            await Database.SaveAsync();
        }
コード例 #2
0
        public async Task <ActionResult> Edit([Bind(Include = "id,FileNameUrl,DateStart,Duration,UserId")] SoundDTO sound)
        {
            if (ModelState.IsValid)
            {
                await soundService.UpdateSound(sound);

                return(RedirectToAction("Index"));
            }
            ViewBag.UserId = new SelectList(soundService.GetUsers(), "id", "value", sound.UserId);
            return(View(sound));
        }
コード例 #3
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            using (AzureBlobManager azureBlobManager = AzureBlobManager.getInstance())
            {
                SoundDTO sound = soundService.GetSound(id);
                await Task.Run(async() => await azureBlobManager.DeleteAsync(sound.FileNameUrl));

                await soundService.DeleteSoundAsync(sound);
            }
            return(RedirectToAction("Index"));
        }
コード例 #4
0
 public async Task MakeSoundAsync(SoundDTO soundDTO)
 {
     if (soundDTO == null)
     {
         throw new ValidationException("Sound is null!", "");
     }
     Database.Sounds.Create(new Sound()
     {
         DateStart = soundDTO.DateStart, UserId = soundDTO.UserId, Duration = soundDTO.Duration, FileNameUrl = soundDTO.FileNameUrl
     });
     Database.Save();
 }
コード例 #5
0
 public async Task UpdateSound(SoundDTO soundDTO)
 {
     if (soundDTO == null)
     {
         throw new ValidationException("Sound is null!", "");
     }
     Database.Sounds.UpdateAsync(new Sound()
     {
         id = soundDTO.id, DateStart = soundDTO.DateStart, UserId = soundDTO.UserId, Duration = soundDTO.Duration, FileNameUrl = soundDTO.FileNameUrl
     });
     await Database.SaveAsync();
 }
コード例 #6
0
        // GET: Sounds/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SoundDTO sound = soundService.GetSound(id);

            if (sound == null)
            {
                return(HttpNotFound());
            }
            return(View(sound));
        }
コード例 #7
0
        // GET: Sounds/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SoundDTO sound = soundService.GetSound(id);

            if (sound == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserId = new SelectList(soundService.GetUsers(), "id", "value", sound.UserId);
            return(View(sound));
        }