public async Task DeleteSoundAsync(SoundDTO soundDTO) { if (soundDTO == null) { throw new ValidationException("Sound is null!", ""); } await Database.Sounds.DeleteAsync(soundDTO.id); await Database.SaveAsync(); }
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)); }
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")); }
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(); }
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(); }
// 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)); }
// 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)); }