コード例 #1
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Get Item
            ReasonCodeItem reasonCodeItem = new ReasonCodeItem();

            reasonCodeItem = reasonCodeItemRepository.GetItem(id);

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

            //Check AccessRights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToReasonCodeGroup(reasonCodeItem.ReasonCodeGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            ReasonCodeProductTypeRepository reasonCodeProductTypeRepository = new ReasonCodeProductTypeRepository();
            SelectList reasonCodeList = new SelectList(reasonCodeProductTypeRepository.GetAllReasonCodeProductTypes().ToList(), "ReasonCodeValue", "ReasonCodeValue");

            ViewData["ReasonCodes"] = reasonCodeList;

            SelectList productList = new SelectList(reasonCodeProductTypeRepository.LookUpReasonCodeProducts(reasonCodeItem.ReasonCode).ToList(), "ProductId", "ProductName");

            ViewData["Products"] = productList;

            SelectList reasonCodeTypeList = new SelectList(reasonCodeProductTypeRepository.LookUpAvailableReasonCodeProductReasonCodeTypes(
                                                               reasonCodeItem.ReasonCodeItemId,
                                                               reasonCodeItem.ReasonCodeGroupId,
                                                               reasonCodeItem.ReasonCode,
                                                               reasonCodeItem.ProductId).ToList(), "ReasonCodeTypeId", "ReasonCodeTypeDescription");

            ViewData["ReasonCodeTypes"] = reasonCodeTypeList;

            //Parent Information
            reasonCodeItemRepository.EditItemForDisplay(reasonCodeItem);
            ViewData["ReasonCodeItem"]      = reasonCodeItem.ReasonCode + "/" + reasonCodeItem.ReasonCodeTypeDescription + "/" + reasonCodeItem.ProductName;
            ViewData["ReasonCodeItemId"]    = reasonCodeItem.ReasonCodeItemId;
            ViewData["ReasonCodeGroupId"]   = reasonCodeItem.ReasonCodeGroupId;
            ViewData["ReasonCodeGroupName"] = reasonCodeGroupRepository.GetGroup(reasonCodeItem.ReasonCodeGroupId).ReasonCodeGroupName;

            reasonCodeItemRepository.EditItemForDisplay(reasonCodeItem);
            return(View(reasonCodeItem));
        }
コード例 #2
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));
        }
        //GET:List
        public ActionResult List(int id, int?page, string sortField, int?sortOrder)
        {
            //Get ReasonCodeItem
            ReasonCodeItem reasonCodeItem = new ReasonCodeItem();

            reasonCodeItem = reasonCodeItemRepository.GetItem(id);


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

            //Set Access Rights
            ViewData["Access"] = "";
            RolesRepository rolesRepository = new RolesRepository();

            if (rolesRepository.HasWriteAccessToReasonCodeGroup(reasonCodeItem.ReasonCodeGroupId))
            {
                ViewData["Access"] = "WriteAccess";
            }

            //Parent Information
            reasonCodeItemRepository.EditItemForDisplay(reasonCodeItem);
            ViewData["ReasonCodeItem"]      = reasonCodeItem.ReasonCode + "/" + reasonCodeItem.ReasonCodeTypeDescription + "/" + reasonCodeItem.ProductName;
            ViewData["ReasonCodeItemId"]    = reasonCodeItem.ReasonCodeItemId;
            ViewData["ReasonCodeGroupId"]   = reasonCodeItem.ReasonCodeGroupId;
            ViewData["ReasonCodeGroupName"] = reasonCodeGroupRepository.GetGroup(reasonCodeItem.ReasonCodeGroupId).ReasonCodeGroupName;
            ViewData["DisplayOrder"]        = reasonCodeItem.DisplayOrder;

            //SortField+SortOrder settings
            if (sortField != "ReasonCodeAlternativeDescription")
            {
                sortField = "LanguageName";
            }
            ViewData["CurrentSortField"] = sortField;

            if (sortOrder == 1)
            {
                ViewData["NewSortOrder"]     = 0;
                ViewData["CurrentSortOrder"] = 1;
            }
            else
            {
                ViewData["NewSortOrder"]     = 1;
                ViewData["CurrentSortOrder"] = 0;
            }

            //Get data
            var paginatedView = reasonCodeAlternativeDescriptionRepository.GetAlternativeDescriptions(id, page ?? 1, sortField, sortOrder ?? 0);

            //Return View
            return(View(paginatedView));
        }
コード例 #4
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));
        }