Esempio n. 1
0
        /*
         * Deletes the selected uploaded requiremensts from the database and azure blob storage.
         * */
        public ActionResult DeleteRequestBlob(string fileName, int?fileID)
        {
            try
            {
                if (User.IsInRole("Student"))
                {
                    if (fileName == null || fileID == null)
                    {
                        return(RedirectToAction("RequestStatus"));
                    }
                    else
                    {
                        if (studentActions.DeleteRequestBlob(fileName))
                        {
                            RequestResource requestResource = studentActions.GetRequestResourceByFileID((int)fileID);
                            studentActions.DeleteFromRequestResource(requestResource);

                            FileLocationStorage fileLocationStorage = studentActions.GetFileLocationStorageByFileID((int)fileID);
                            studentActions.DeleteFromFileLocationStorage(fileLocationStorage);

                            return(RedirectToAction("EditRequest", new { requestID = requestResource.RequestID }));
                        }
                        TempData["errorMessage"] = "There was an error in the server. Please try again.";
                        return(RedirectToAction("RequestStatus"));
                    }
                }
                else
                {
                    TempData["errorMessage"] = "Sorry you do not have access.";
                    return(RedirectToAction("Announcement", "WebsiteContent"));
                }
            }
            catch (Exception e)
            {
                TempData["errorMessage"] = "There was an error in deletings. Please try again, thank you!";
                return(RedirectToAction("RequestStatus"));
            }
        }