Esempio n. 1
0
 public void Create(PlaylistCreateViewModel model)
 {
     _logger.InfoFormat("Se ejecuto el Metodo {0}", MethodBase.GetCurrentMethod().Name);
     var customer = _customerRepository.Get().FirstOrDefault(c => c.Email == model.CustomerUserName);
     if (customer == null) throw new InvalidOperationException(string.Format("Cliente no encontrado {0}", model.CustomerUserName));
     var playList = new Playlist(){Name = model.Nombre,CustomerId = customer.Id};
     _playListRepository.Create(playList);
 }
Esempio n. 2
0
 public ActionResult Create(PlaylistCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             model.CustomerUserName = User.Identity.Name;
             _playListService.Create(model);
             return RedirectToAction("Index");
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("",ex);
             ViewBag.Title = "New Playlist";
             return View(model);
         }
     }
     ModelState.AddModelError("","Model is invalid");
     return View(model);
 }