Exemple #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));
        }
Exemple #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));
        }
Exemple #3
0
        public ActionResult Create(ReasonCodeProductTypeTravelerDescription reasonCodeProductTypeTravelerDescription)
        {
            //Get Item
            ReasonCodeProductType reasonCodeProductType = new ReasonCodeProductType();

            reasonCodeProductType = reasonCodeProductTypeRepository.GetReasonCodeProductType(reasonCodeProductTypeTravelerDescription.ReasonCode, reasonCodeProductTypeTravelerDescription.ProductId, reasonCodeProductTypeTravelerDescription.ReasonCodeTypeId);

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

            //Update  Model from Form
            try
            {
                UpdateModel(reasonCodeProductTypeTravelerDescription);
            }
            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"));
            }


            reasonCodeProductTypeTravelerDescriptionRepository.Add(reasonCodeProductTypeTravelerDescription);

            return(RedirectToAction("List", new { reasonCode = reasonCodeProductTypeTravelerDescription.ReasonCode, productId = reasonCodeProductTypeTravelerDescription.ProductId, reasonCodeTypeId = reasonCodeProductTypeTravelerDescription.ReasonCodeTypeId }));
        }