コード例 #1
0
        public ActionResult Edit(AlbumModel albumModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var userID        = User.Identity.GetID();
                    var isAlbumEdited = _albumManager.EditAlbum(albumModel, userID);
                    if (isAlbumEdited)
                    {
                        TempData[Alert.AlertMsgKey]  = "Album Edited Successfully...";
                        TempData[Alert.AlertTypeKey] = Alert.AlertSuccess;
                    }
                }
                catch (Exception e)
                {
                    //write error msg to log file
                    Console.WriteLine($"{e.Message} ---> {e.Source}");

                    //Display error msg
                    TempData[Alert.AlertMsgKey]  = "Ooops!!!...failed to edit album";
                    TempData[Alert.AlertTypeKey] = Alert.AlertDanger;
                }
            }
            else
            {
                TempData[Alert.AlertMsgKey]  = "Pls fill form appropriately";
                TempData[Alert.AlertTypeKey] = Alert.AlertDanger;
            }

            return(RedirectToAction("Index", "Home", new { alert = true }));
        }