Example #1
0
        public ActionResult Delete(int id)
        {
            ChatMessageFAQVM chatMessageFAQVM = new ChatMessageFAQVM();

            ChatMessageFAQ chatMessageFAQ = new ChatMessageFAQ();

            chatMessageFAQ = chatMessageFAQRepository.GetChatMessageFAQ(id);

            //Check Exists
            if (chatMessageFAQ == null)
            {
                ViewData["ActionMethod"] = "ViewGet";
                return(View("RecordDoesNotExistError"));
            }

            chatMessageFAQVM.ChatMessageFAQ = chatMessageFAQ;

            //Attached Items
            List <ChatMessageFAQReference> chatMessageFAQReferences = chatMessageFAQRepository.GetChatMessageFAQReferences(chatMessageFAQ.ChatMessageFAQId);

            if (chatMessageFAQReferences.Count > 0)
            {
                chatMessageFAQVM.AllowDelete = false;
                chatMessageFAQVM.ChatMessageFAQReferences = chatMessageFAQReferences;
            }

            chatMessageFAQRepository.EditForDisplay(chatMessageFAQ);

            return(View(chatMessageFAQVM));
        }
Example #2
0
        public ActionResult Delete(ChatMessageFAQVM chatMessageFAQVM)
        {
            //Get Item
            ChatMessageFAQ chatMessageFAQ = new ChatMessageFAQ();

            chatMessageFAQ = chatMessageFAQRepository.GetChatMessageFAQ(chatMessageFAQVM.ChatMessageFAQ.ChatMessageFAQId);

            //Check Exists
            if (chatMessageFAQVM.ChatMessageFAQ == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                return(View("RecordDoesNotExistError"));
            }

            //Check Access Rights to Domain
            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Delete Item
            try
            {
                chatMessageFAQRepository.Delete(chatMessageFAQ);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/ChatMessageFAQ.mvc/Delete/" + chatMessageFAQ.ChatMessageFAQId;
                    return(View("VersionError"));
                }

                //Generic Error
                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }

            //Return
            return(RedirectToAction("List"));
        }