Beispiel #1
0
        //Delete From DB
        public void Delete(ReasonCodeProductTypeDescription reasonCodeProductTypeDescription)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_DeleteReasonCodeProductTypeDescription_v1(
                reasonCodeProductTypeDescription.ReasonCode,
                reasonCodeProductTypeDescription.ProductId,
                reasonCodeProductTypeDescription.ReasonCodeTypeId,
                reasonCodeProductTypeDescription.LanguageCode,
                adminUserGuid,
                reasonCodeProductTypeDescription.VersionNumber
                );
        }
        //GET: View
        public ActionResult View(string reasonCode, int productId, int reasonCodeTypeId, string languageCode)
        {
            ReasonCodeProductTypeDescription reasonCodeProductTypeDescription = new ReasonCodeProductTypeDescription();

            reasonCodeProductTypeDescription = reasonCodeProductTypeDescriptionRepository.GetItem(languageCode, reasonCode, productId, reasonCodeTypeId);
            if (reasonCodeProductTypeDescription == null)
            {
                ViewData["ActionMethod"] = "ViewGet";
                return(View("RecordDoesNotExistError"));
            }
            reasonCodeProductTypeDescriptionRepository.EditItemForDisplay(reasonCodeProductTypeDescription);
            return(View(reasonCodeProductTypeDescription));
        }
Beispiel #3
0
        //Add to DB
        public void Add(ReasonCodeProductTypeDescription reasonCodeProductTypeDescription)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_InsertReasonCodeProductTypeDescription_v1(
                reasonCodeProductTypeDescription.ReasonCode,
                reasonCodeProductTypeDescription.ProductId,
                reasonCodeProductTypeDescription.ReasonCodeTypeId,
                reasonCodeProductTypeDescription.LanguageCode,
                reasonCodeProductTypeDescription.ReasonCodeProductTypeDescription1,
                adminUserGuid
                );
        }
Beispiel #4
0
 //Add Data From Linked Tables for Display
 public void EditItemForDisplay(ReasonCodeProductTypeDescription reasonCodeProductTypeDescription)
 {
     //Add LanguageName
     if (reasonCodeProductTypeDescription.LanguageCode != null)
     {
         LanguageRepository languageRepository = new LanguageRepository();
         Language           language           = new Language();
         language = languageRepository.GetLanguage(reasonCodeProductTypeDescription.LanguageCode);
         if (language != null)
         {
             reasonCodeProductTypeDescription.LanguageName = language.LanguageName;
         }
     }
 }
        // 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"));
            }

            //New ReasonCodeProductTypeDescription
            ReasonCodeProductTypeDescription reasonCodeProductTypeDescription = new ReasonCodeProductTypeDescription();

            reasonCodeProductTypeDescription.ReasonCode       = reasonCode;
            reasonCodeProductTypeDescription.ProductId        = productId;
            reasonCodeProductTypeDescription.ReasonCodeTypeId = reasonCodeTypeId;
            reasonCodeProductTypeDescriptionRepository.EditItemForDisplay(reasonCodeProductTypeDescription);

            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;

            //Show Create Form
            return(View(reasonCodeProductTypeDescription));
        }
        public ActionResult Delete(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"] = "DeleteGet";
                return(View("RecordDoesNotExistError"));
            }

            //Add Linked Information
            reasonCodeProductTypeDescriptionRepository.EditItemForDisplay(reasonCodeProductTypeDescription);

            //Return View
            return(View(reasonCodeProductTypeDescription));
        }
        public ActionResult Delete(string reasonCode, int productId, int reasonCodeTypeId, string languageCode, FormCollection collection)
        {
            //Get Item
            ReasonCodeProductTypeDescription reasonCodeProductTypeDescription = new ReasonCodeProductTypeDescription();

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

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

            //Delete Item
            try
            {
                reasonCodeProductTypeDescription.VersionNumber = Int32.Parse(collection["VersionNumber"]);
                reasonCodeProductTypeDescriptionRepository.Delete(reasonCodeProductTypeDescription);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/AirlineAdvice.mvc/Delete?reasonCodeTypeId=" + reasonCodeTypeId.ToString()
                                            + "&languagCode=" + languageCode
                                            + "&reasonCode=" + reasonCode.ToString()
                                            + "&productId=" + productId.ToString()
                                            + "&reasonCodeTypeId=" + reasonCodeTypeId.ToString();
                    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 { reasonCode = reasonCode, productId = productId, reasonCodeTypeId = reasonCodeTypeId }));
        }
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(ReasonCodeItem reasonCodeItem)
        {
            ProductRepository productRepository = new ProductRepository();
            Product           product           = new Product();

            product = productRepository.GetProduct(reasonCodeItem.ProductId);
            if (product != null)
            {
                reasonCodeItem.ProductName = product.ProductName;
            }

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

            reasonCodeType = reasonCodeTypeRepository.GetItem(reasonCodeItem.ReasonCodeTypeId);
            if (reasonCodeType != null)
            {
                reasonCodeItem.ReasonCodeTypeDescription = reasonCodeType.ReasonCodeTypeDescription;
            }

            ReasonCodeProductTypeDescriptionRepository reasonCodeProductTypeDescriptionRepository = new ReasonCodeProductTypeDescriptionRepository();
            ReasonCodeProductTypeDescription           reasonCodeProductTypeDescription           = new ReasonCodeProductTypeDescription();

            reasonCodeProductTypeDescription = reasonCodeProductTypeDescriptionRepository.GetItem(
                "en-GB",
                reasonCodeItem.ReasonCode,
                reasonCodeItem.ProductId,
                reasonCodeItem.ReasonCodeTypeId
                );
            reasonCodeItem.ReasonCodeDescription = (reasonCodeProductTypeDescription != null) ? reasonCodeProductTypeDescription.ReasonCodeProductTypeDescription1 : String.Empty;

            ReasonCodeGroupRepository reasonCodeGroupRepository = new ReasonCodeGroupRepository();
            ReasonCodeGroup           reasonCodeGroup           = new ReasonCodeGroup();

            reasonCodeGroup = reasonCodeGroupRepository.GetGroup(reasonCodeItem.ReasonCodeGroupId);
            if (reasonCodeGroup != null)
            {
                reasonCodeItem.ReasonCodeGroupName = reasonCodeGroup.ReasonCodeGroupName;
            }
        }
        public ActionResult Create(ReasonCodeProductTypeDescription reasonCodeProductTypeDescription)
        {
            //Get Item
            ReasonCodeProductType reasonCodeProductType = new ReasonCodeProductType();

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

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

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


            reasonCodeProductTypeDescriptionRepository.Add(reasonCodeProductTypeDescription);

            return(RedirectToAction("List", new { reasonCode = reasonCodeProductTypeDescription.ReasonCode, productId = reasonCodeProductTypeDescription.ProductId, reasonCodeTypeId = reasonCodeProductTypeDescription.ReasonCodeTypeId }));
        }
        public ActionResult Edit(string reasonCode, int productId, int reasonCodeTypeId, string languageCode, FormCollection formCollection)
        {
            //Get Item
            ReasonCodeProductTypeDescription reasonCodeProductTypeDescription = new ReasonCodeProductTypeDescription();

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

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



            //Update Item from Form
            try
            {
                UpdateModel(reasonCodeProductTypeDescription);
            }
            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
            {
                reasonCodeProductTypeDescriptionRepository.Update(reasonCodeProductTypeDescription);
            }
            catch (SqlException ex)
            {
                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/ReasonCodeProductTypeDescription.mvc/Edit?reasonCodeTypeId=" + reasonCodeTypeId.ToString()
                                            + "&languagCode=" + languageCode
                                            + "&reasonCode=" + reasonCode.ToString()
                                            + "&productId=" + productId.ToString()
                                            + "&reasonCodeTypeId=" + reasonCodeTypeId.ToString();
                    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 { reasonCode = reasonCode, productId = productId, reasonCodeTypeId = reasonCodeTypeId }));
        }