Пример #1
0
        // GET: /Create
        public ActionResult Create(int id)
        {
            MeetingPNROutput meetingPNROutput = new MeetingPNROutput();

            meetingPNROutput = meetingPNROutputRepository.GetMeetingPNROutput(id);

            //Check Exists
            if (meetingPNROutput == null)
            {
                ViewData["ActionMethod"] = "CreateGet";
                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"));
            }

            MeetingPNROutputLanguageVM meetingPNROutputLanguageVM = new MeetingPNROutputLanguageVM();

            Meeting meeting = new Meeting();

            meeting = meetingRepository.GetGroup(meetingPNROutput.MeetingID);

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

            meetingRepository.EditGroupForDisplay(meeting);

            ViewData["ClientTopUnitGuid"]  = meeting.ClientTopUnitGuid;
            ViewData["ClientTopUnitName"]  = meeting.ClientTopUnit.ClientTopUnitName;
            ViewData["MeetingID"]          = meeting.MeetingID;
            ViewData["MeetingName"]        = meeting.MeetingName;
            ViewData["MeetingPNROutputId"] = meetingPNROutput.MeetingPNROutputId;

            MeetingPNROutputLanguage meetingPNROutputLanguage = new MeetingPNROutputLanguage();

            meetingPNROutputLanguage.MeetingPNROutputId = meetingPNROutput.MeetingPNROutputId;

            meetingPNROutputLanguageVM.MeetingPNROutputLanguage = meetingPNROutputLanguage;
            meetingPNROutputLanguageVM.MeetingPNROutput         = meetingPNROutput;

            //Languages
            LanguageRepository languageRepository = new LanguageRepository();

            meetingPNROutputLanguageVM.Languages = new SelectList(meetingPNROutputLanguageRepository.GetAvailableLanguages(meetingPNROutput.MeetingPNROutputId).ToList(), "LanguageCode", "LanguageName");

            return(View(meetingPNROutputLanguageVM));
        }
Пример #2
0
        public ActionResult Delete(MeetingPNROutputLanguageVM meetingPNROutputLanguageVM)
        {
            MeetingPNROutputLanguage meetingPNROutputLanguage = new MeetingPNROutputLanguage();

            meetingPNROutputLanguage = meetingPNROutputLanguageRepository.GetMeetingPNROutputLanguage(
                meetingPNROutputLanguageVM.MeetingPNROutputLanguage.MeetingPNROutputId,
                meetingPNROutputLanguageVM.MeetingPNROutputLanguage.LanguageCode
                );

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

            MeetingPNROutput meetingPNROutput = new MeetingPNROutput();

            meetingPNROutput = meetingPNROutputRepository.GetMeetingPNROutput(
                meetingPNROutputLanguage.MeetingPNROutputId
                );

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

            Meeting meeting = new Meeting();

            meeting = meetingRepository.GetGroup(meetingPNROutput.MeetingID);

            //Check Exists
            if (meeting == 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
            {
                meetingPNROutputLanguageRepository.Delete(meetingPNROutputLanguage);
            }
            catch (SqlException ex)
            {
                //Non-Unique Name
                if (ex.Message == "NonUniqueName")
                {
                    return(View("NonUniqueNameError"));
                }
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                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 = meetingPNROutputLanguageVM.MeetingPNROutput.MeetingPNROutputId
            }));
        }
Пример #3
0
        public ActionResult Edit(MeetingPNROutputLanguageVM meetingPNROutputLanguageVM)
        {
            MeetingPNROutputLanguage meetingPNROutputLanguage = new MeetingPNROutputLanguage();

            meetingPNROutputLanguage = meetingPNROutputLanguageRepository.GetMeetingPNROutputLanguage(
                meetingPNROutputLanguageVM.MeetingPNROutputLanguage.MeetingPNROutputId,
                meetingPNROutputLanguageVM.MeetingPNROutputLanguage.CurrentLanguageCode
                );

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

            Meeting meeting = new Meeting();

            meeting = meetingRepository.GetGroup(meetingPNROutputLanguageVM.MeetingPNROutput.MeetingID);

            //Check Exists
            if (meeting == null)
            {
                ViewData["ActionMethod"] = "EditPost";
                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"));
            }

            //Update Model From Form + Validate against DB
            try
            {
                UpdateModel(meetingPNROutputLanguageVM);
            }
            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"));
            }

            //Database Update
            try
            {
                meetingPNROutputLanguageRepository.Update(meetingPNROutputLanguageVM.MeetingPNROutputLanguage);
            }
            catch (SqlException ex)
            {
                //Non-Unique Name
                if (ex.Message == "NonUniqueName")
                {
                    return(View("NonUniqueNameError"));
                }
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                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 = meetingPNROutputLanguageVM.MeetingPNROutput.MeetingPNROutputId,
            }));
        }