예제 #1
0
 public ActionResult Create(Album item)
 {
     if(ModelState.IsValid)
     {
         _repository.Add(item);
         return RedirectToAction("Index");
     }
     else
     {
         return View();
     }
 }
예제 #2
0
        public ActionResult Edit(Album item)
        {
            if(ModelState.IsValid)
            {
                string resultMessage = "";
                try {
                    _repository.Update(item);
                    resultMessage = item.DescriptorValue() + " updated!";
                } catch(Exception x) {
                    //edit this to return a message
                    resultMessage = "ERROR: "+ item.DescriptorValue() + " failed: "+x.Message;

                }
                //if this is an Ajax request - just send back a message
                if (Request.IsAjaxRequest()) {
                    return Content(resultMessage);
                } else {
                    return RedirectToAction("Index");
                }
            }
            else
            {
                return View();
            }
        }