示例#1
0
        public ActionResult RemovePhoto(int photoID)
        {
            ActionResult response = null;

            if (Session["RoleID"] != null && (byte)Session["RoleID"] >= 2)
            {
                try
                {
                    _dataAccess.DeletePhoto(photoID);
                    response = RedirectToAction("ViewAllPhotos", "Photo");
                }
                catch (Exception ex)
                {
                    LogFile.DataFile(ex: ex);
                }
                finally
                {
                }
            }
            else
            {
                TempData["Statement"] = "Please contact Admin to gain permissions to the page you are requesting.";
                response = RedirectToAction("Index", "Home");
            }

            return(response);
        }
        public ActionResult Delete(long photoId)
        {
            //Defaults redirect to Index of album controllor.
            ActionResult oResult = RedirectToAction("Index", "Album");

            if (ModelState.IsValid)
            {
                try
                {
                    //Passing photo object and photo location by photoId to use in a stored procedure for delete.
                    dataAccess.DeletePhoto(photoId, dataAccess.ViewPhotoLocation(photoId));
                    TempData["Message"] = "Photo successfully deleted.";
                }
                catch (Exception ex)
                {
                    //Logs exception using exceptionLog class.
                    exceptionLog.ExceptionLog("Critical", ex.Message, "PhotosController", "Index", ex.StackTrace);
                    oResult = View(photoId);
                }
            }
            else
            {
                //Returning photoId to view.
                oResult = View(photoId);
            }

            return(oResult);
        }