Example #1
0
        public bool CreatePersonalAudio(PersonalAudioCreate model)
        {
            var entity = new PersonalAudio()
            {
                Id           = _userId,
                AudioName    = model.AudioName,
                AudioMessage = model.AudioMessage,
                CreatedUTC   = DateTimeOffset.Now,
                PlaylistId   = model.PlaylistId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.PersonalAudios.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Example #2
0
        public ActionResult Create(PersonalAudioCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreatePersonalAudioService();

            if (service.CreatePersonalAudio(model))
            {
                TempData["SaveResult"] = "Your personal audio was created.";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Personal Audio could not be created.");
            return(View(model));
        }