Beispiel #1
0
        public ActionResult List(string reasonCode, int productId, int reasonCodeTypeId, int?page, string sortField, int?sortOrder)
        {
            //Get ReasonCodeProductType
            ReasonCodeProductType reasonCodeProductType = new ReasonCodeProductType();

            reasonCodeProductType = reasonCodeProductTypeRepository.GetReasonCodeProductType(reasonCode, productId, reasonCodeTypeId);

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

            //Set Access Rights
            ViewData["Access"] = "WriteAccess";

            //Parent Information
            ViewData["ReasonCode"]       = reasonCode;
            ViewData["ReasonCodeTypeId"] = reasonCodeTypeId;
            ViewData["ProductId"]        = productId;

            ProductRepository productRepository = new ProductRepository();
            Product           product           = new Product();

            product = productRepository.GetProduct(productId);
            ReasonCodeTypeRepository reasonCodeTypeRepository = new ReasonCodeTypeRepository();
            ReasonCodeType           reasonCodeType           = new ReasonCodeType();

            reasonCodeType = reasonCodeTypeRepository.GetItem(reasonCodeTypeId);
            ReasonCodeItemRepository reasonCodeItemRepository = new ReasonCodeItemRepository();
            ReasonCodeItem           reasonCodeItem           = new ReasonCodeItem();

            reasonCodeItem             = reasonCodeItemRepository.GetItem(1);
            ViewData["ReasonCodeItem"] = reasonCode + "/" + reasonCodeType.ReasonCodeTypeDescription + "/" + product.ProductName;


            //SortField+SortOrder settings
            if (sortField != "ReasonCodeProductTypeTravelerDescription")
            {
                sortField = "LanguageName";
            }
            if (sortOrder == 1)
            {
                ViewData["NewSortOrder"]     = 0;
                ViewData["CurrentSortOrder"] = 1;
            }
            else
            {
                ViewData["NewSortOrder"]     = 1;
                ViewData["CurrentSortOrder"] = 0;
                sortOrder = 0;
            }

            //Get data
            var cwtPaginatedList = reasonCodeProductTypeTravelerDescriptionRepository.PageReasonCodeProductTypeTravelerDescriptions(reasonCode, productId, reasonCodeTypeId, page ?? 1, sortField, sortOrder ?? 0);

            return(View(cwtPaginatedList));
        }
Beispiel #2
0
        // GET: /Create
        public ActionResult Create(string reasonCode, int productId, int reasonCodeTypeId)
        {
            //Get Item
            ReasonCodeProductType reasonCodeProductType = new ReasonCodeProductType();

            reasonCodeProductType = reasonCodeProductTypeRepository.GetReasonCodeProductType(reasonCode, productId, reasonCodeTypeId);

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

            //ReasonCodeProductTypeTravelerDescription
            ReasonCodeProductTypeTravelerDescriptionRepository reasonCodeProductTypeTravelerDescriptionRepository = new ReasonCodeProductTypeTravelerDescriptionRepository();
            ReasonCodeProductTypeTravelerDescription           reasonCodeProductTypeTravelerDescription           = new ReasonCodeProductTypeTravelerDescription();

            //ReasonCodeProductTypeTravelerDescription Label
            ReasonCodeProductTypeTravelerDescription reasonCodeProductTypeTravelerDescriptionLabel = new ReasonCodeProductTypeTravelerDescription();

            reasonCodeProductTypeTravelerDescriptionLabel = reasonCodeProductTypeTravelerDescriptionRepository.GetItem("en-GB", reasonCode, productId, reasonCodeTypeId);
            ViewData["ReasonCodeProductTypeDescription"]  = (reasonCodeProductTypeTravelerDescriptionLabel != null) ?
                                                            reasonCodeProductTypeTravelerDescriptionLabel.ReasonCodeProductTypeTravelerDescription1 : String.Empty;

            //ProductRepository
            ProductRepository productRepository = new ProductRepository();
            Product           product           = new Product();

            product = productRepository.GetProduct(productId);

            //ReasonCodeType
            ReasonCodeTypeRepository reasonCodeTypeRepository = new ReasonCodeTypeRepository();
            ReasonCodeType           reasonCodeType           = new ReasonCodeType();

            reasonCodeType = reasonCodeTypeRepository.GetItem(reasonCodeTypeId);

            //ReasonCodeItem
            ReasonCodeItemRepository reasonCodeItemRepository = new ReasonCodeItemRepository();
            ReasonCodeItem           reasonCodeItem           = new ReasonCodeItem();

            reasonCodeItem             = reasonCodeItemRepository.GetItem(1);
            ViewData["ReasonCodeItem"] = reasonCode + "/" + reasonCodeType.ReasonCodeTypeDescription + "/" + product.ProductName;

            //Language SelectList
            SelectList languageList = new SelectList(reasonCodeProductTypeTravelerDescriptionRepository.GetUnUsedLanguages(reasonCode, productId, reasonCodeTypeId).ToList(), "LanguageCode", "LanguageName");

            ViewData["Languages"] = languageList;

            //Show Create Form
            return(View(reasonCodeProductTypeTravelerDescription));
        }
        // GET: /Edit
        public ActionResult Edit(string reasonCode, int productId, int reasonCodeTypeId, string languageCode)
        {
            //Get Item
            ReasonCodeProductTypeDescription reasonCodeProductTypeDescription = new ReasonCodeProductTypeDescription();

            reasonCodeProductTypeDescription = reasonCodeProductTypeDescriptionRepository.GetItem(languageCode, reasonCode, productId, reasonCodeTypeId);

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

            ProductRepository productRepository = new ProductRepository();
            Product           product           = new Product();

            product = productRepository.GetProduct(productId);
            ReasonCodeTypeRepository reasonCodeTypeRepository = new ReasonCodeTypeRepository();
            ReasonCodeType           reasonCodeType           = new ReasonCodeType();

            reasonCodeType = reasonCodeTypeRepository.GetItem(reasonCodeTypeId);
            ReasonCodeItemRepository reasonCodeItemRepository = new ReasonCodeItemRepository();
            ReasonCodeItem           reasonCodeItem           = new ReasonCodeItem();

            reasonCodeItem             = reasonCodeItemRepository.GetItem(1);
            ViewData["ReasonCodeItem"] = reasonCode + "/" + reasonCodeType.ReasonCodeTypeDescription + "/" + product.ProductName;

            //Language SelectList
            SelectList languageList = new SelectList(reasonCodeProductTypeDescriptionRepository.GetUnUsedLanguages(reasonCode, productId, reasonCodeTypeId).ToList(), "LanguageCode", "LanguageName");

            ViewData["Languages"] = languageList;

            reasonCodeProductTypeDescriptionRepository.EditItemForDisplay(reasonCodeProductTypeDescription);
            return(View(reasonCodeProductTypeDescription));
        }