Пример #1
0
        public ActionResult Delete(int id, string languageCode)
        {
            //Get Item
            ChatFAQResponseItemLanguage chatFAQResponseItemLanguage = new ChatFAQResponseItemLanguage();

            chatFAQResponseItemLanguage = chatFAQResponseItemLanguageRepository.GetItem(id, languageCode);

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

            //AccessRights
            HierarchyRepository hierarchyRepository = new HierarchyRepository();

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

            //Get ChatFAQResponseItem
            ChatFAQResponseItem chatFAQResponseItem = new ChatFAQResponseItem();

            chatFAQResponseItem = chatFAQResponseItemRepository.GetItem(chatFAQResponseItemLanguage.ChatFAQResponseItemId);

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

            //ChatFAQResponseItem
            chatFAQResponseItemRepository.EditItemForDisplay(chatFAQResponseItem);

            //ChatFAQResponseItemLanguage
            chatFAQResponseItemLanguage.ChatFAQResponseItemId = id;
            chatFAQResponseItemLanguage.ChatFAQResponseItem   = chatFAQResponseItem;
            chatFAQResponseItemLanguageRepository.EditItemForDisplay(chatFAQResponseItemLanguage);

            //Language SelectList
            SelectList languageList = new SelectList(chatFAQResponseItemLanguageRepository.GetUnUsedLanguages(id).ToList(), "LanguageCode", "LanguageName");

            ViewData["Languages"] = languageList;

            //View data
            ViewData["ChatFAQResponseItemId"]          = id;
            ViewData["ChatFAQResponseItemDescription"] = chatFAQResponseItem.ChatFAQResponseItemDescription;
            ViewData["ChatFAQResponseGroupId"]         = chatFAQResponseItem.ChatFAQResponseGroup.ChatFAQResponseGroupId;
            ViewData["ChatFAQResponseGroupName"]       = chatFAQResponseItem.ChatFAQResponseGroup.ChatFAQResponseGroupName;
            ViewData["ChatMessageFAQName"]             = chatFAQResponseItem.ChatMessageFAQName;

            return(View(chatFAQResponseItemLanguage));
        }
Пример #2
0
        //Delete From DB
        public void Delete(ChatFAQResponseItemLanguage chatFAQResponseItemLanguage)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_DeleteChatFAQResponseItemLanguage_v1(
                chatFAQResponseItemLanguage.ChatFAQResponseItemId,
                chatFAQResponseItemLanguage.LanguageCode,
                adminUserGuid,
                chatFAQResponseItemLanguage.VersionNumber
                );
        }
Пример #3
0
        //Add to DB
        public void Add(ChatFAQResponseItemLanguage chatFAQResponseItemLanguage)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_InsertChatFAQResponseItemLanguage_v1(
                chatFAQResponseItemLanguage.ChatFAQResponseItemId,
                chatFAQResponseItemLanguage.LanguageCode,
                chatFAQResponseItemLanguage.ChatFAQResponseItemLanguageDescription,
                adminUserGuid
                );
        }
Пример #4
0
 //Add Data From Linked Tables for Display
 public void EditItemForDisplay(ChatFAQResponseItemLanguage chatFAQResponseItemLanguage)
 {
     //Add LanguageName
     if (chatFAQResponseItemLanguage.LanguageCode != null)
     {
         LanguageRepository languageRepository = new LanguageRepository();
         Language           language           = new Language();
         language = languageRepository.GetLanguage(chatFAQResponseItemLanguage.LanguageCode);
         if (language != null)
         {
             chatFAQResponseItemLanguage.LanguageName = language.LanguageName;
         }
     }
 }
Пример #5
0
        public ActionResult Delete(int id, string languageCode, FormCollection collection)
        {
            //Get Item
            ChatFAQResponseItemLanguage chatFAQResponseItemLanguage = new ChatFAQResponseItemLanguage();

            chatFAQResponseItemLanguage = chatFAQResponseItemLanguageRepository.GetItem(id, languageCode);

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

            //AccessRights
            HierarchyRepository hierarchyRepository = new HierarchyRepository();

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

            //Delete Item
            try
            {
                chatFAQResponseItemLanguage.VersionNumber = Int32.Parse(collection["VersionNumber"]);
                chatFAQResponseItemLanguageRepository.Delete(chatFAQResponseItemLanguage);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/ChatFAQResponseItemLanguage.mvc/Delete?id=" + chatFAQResponseItemLanguage.ChatFAQResponseItemId + "&languageCode=" + chatFAQResponseItemLanguage.LanguageCode;
                    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", new { id = chatFAQResponseItemLanguage.ChatFAQResponseItemId }));
        }
Пример #6
0
        public ActionResult Create(ChatFAQResponseItemLanguage chatFAQResponseItemLanguage)
        {
            //Get ChatFAQResponseItem
            ChatFAQResponseItem chatFAQResponseItem = new ChatFAQResponseItem();

            chatFAQResponseItem = chatFAQResponseItemRepository.GetItem(chatFAQResponseItemLanguage.ChatFAQResponseItemId);

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

            HierarchyRepository hierarchyRepository = new HierarchyRepository();

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

            //Update  Model from Form
            try
            {
                UpdateModel(chatFAQResponseItemLanguage);
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }


            chatFAQResponseItemLanguageRepository.Add(chatFAQResponseItemLanguage);

            return(RedirectToAction("List", new { id = chatFAQResponseItemLanguage.ChatFAQResponseItemId }));
        }
Пример #7
0
        public ActionResult Edit(int id, string languageCode, FormCollection formCollection)
        {
            //Get Item
            ChatFAQResponseItemLanguage chatFAQResponseItemLanguage = new ChatFAQResponseItemLanguage();

            chatFAQResponseItemLanguage = chatFAQResponseItemLanguageRepository.GetItem(id, languageCode);

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

            //AccessRights
            HierarchyRepository hierarchyRepository = new HierarchyRepository();

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

            //Update Item from Form
            try
            {
                UpdateModel(chatFAQResponseItemLanguage);

                if (!string.IsNullOrEmpty(formCollection["NewLanguageCode"]))
                {
                    chatFAQResponseItemLanguage.LanguageCode = formCollection["NewLanguageCode"];
                }
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            //Update
            try
            {
                chatFAQResponseItemLanguageRepository.Update(chatFAQResponseItemLanguage);
            }
            catch (SqlException ex)
            {
                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/ChatFAQResponseItemLanguage.mvc/Edit?id=" + chatFAQResponseItemLanguage.ChatFAQResponseItemId + "&languageCode=" + chatFAQResponseItemLanguage.LanguageCode;
                    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(RedirectToAction("List", new { id = chatFAQResponseItemLanguage.ChatFAQResponseItemId }));
        }