Ejemplo n.º 1
0
        public ActionResult AddProduct(PackageContents pc)
        {
            pc.packageID = Convert.ToInt32(Session["packageID"]);
            /*db.PackageContents.Add(pc);*/

            /*db.Database.ExecuteSqlCommand("INSERT INTO owis.PackageContents(packageID, productID, productQuantity)" +
             * "Values('" + pc.packageID + "','" + pc.productID + "','" + pc.productQuantity + "')");*/
            db.PackageContents.Add(pc);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public ActionResult UpdatePackageProduct(PackageContents pc)
        {
            int             u_pc      = db.getPackageContents.Where(p => p.packageID == pc.packageID).Where(p => p.productID == pc.productID).First().productQuantity.Value;
            int             u_product = db.Products.Where(p => p.productID == pc.productID).FirstOrDefault().totalQuantity;
            PackageContents pcontent  = new PackageContents();

            if (pc.productQuantity > u_product)
            {
                ModelState.AddModelError("", "Product quantity is not enough!");
                return(View());
            }
            pcontent.packageID       = pc.packageID;
            pcontent.productID       = pc.productID;
            pcontent.productQuantity = pc.productQuantity - u_pc;
            db.PackageContents.Add(pcontent);
            db.SaveChanges();
            return(RedirectToAction("DetailPackage", new { id = pc.packageID }));
        }
Ejemplo n.º 3
0
        private bool CheckPackageValidity()
        {
            if (Name.Contains(@"\") || Name.Contains(@"/") || Name.Contains(@"*"))
            {
                ErrorString = Resources.PackageNameCannotContainTheseCharacters;
                return(false);
            }

            if (Name.Length < 3)
            {
                ErrorString = Resources.NameNeedMoreCharacters;
                return(false);
            }

            if (Description.Length <= 10)
            {
                ErrorString = Resources.DescriptionNeedMoreCharacters;
                return(false);
            }

            if (MajorVersion.Length <= 0)
            {
                ErrorString = Resources.MajorVersionNonNegative;
                return(false);
            }

            if (MinorVersion.Length <= 0)
            {
                ErrorString = Resources.MinorVersionNonNegative;
                return(false);
            }

            if (BuildVersion.Length <= 0)
            {
                ErrorString = Resources.BuildVersionNonNegative;
                return(false);
            }

            if (Double.Parse(BuildVersion) + Double.Parse(MinorVersion) + Double.Parse(MajorVersion) <= 0)
            {
                ErrorString = Resources.VersionValueGreaterThan0;
                return(false);
            }

            if (!PackageContents.Any())
            {
                ErrorString = Resources.PackageNeedAtLeastOneFile;
                return(false);
            }

            if (UploadState != PackageUploadHandle.State.Error)
            {
                ErrorString = "";
            }

            if (Uploading)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Delegate used to submit the element </summary>
        private bool CanSubmit()
        {
            // Typically, this code should never be seen as the publish package dialogs should not
            // be active when there is no authenticator
            if (dynamoViewModel == null || !dynamoViewModel.Model.PackageManagerClient.HasAuthProvider)
            {
                ErrorString = Resources.CannotSubmitPackage;
                return(false);
            }

            if (Name.Contains(@"\") || Name.Contains(@"/") || Name.Contains(@"*"))
            {
                ErrorString = Resources.PackageNameCannotContainTheseCharacters;
                return(false);
            }

            if (Name.Length < 3)
            {
                ErrorString = Resources.NameNeedMoreCharacters;
                return(false);
            }

            if (Description.Length <= 10)
            {
                ErrorString = Resources.DescriptionNeedMoreCharacters;
                return(false);
            }

            if (MajorVersion.Length <= 0)
            {
                ErrorString = Resources.MajorVersionNonNegative;
                return(false);
            }

            if (MinorVersion.Length <= 0)
            {
                ErrorString = Resources.MinorVersionNonNegative;
                return(false);
            }

            if (BuildVersion.Length <= 0)
            {
                ErrorString = Resources.BuildVersionNonNegative;
                return(false);
            }

            if (Double.Parse(BuildVersion) + Double.Parse(MinorVersion) + Double.Parse(MajorVersion) <= 0)
            {
                ErrorString = Resources.VersionValueGreaterThan0;
                return(false);
            }

            if (!PackageContents.Any())
            {
                ErrorString = Resources.PackageNeedAtLeastOneFile;
                return(false);
            }

            if (UploadState != PackageUploadHandle.State.Error)
            {
                ErrorString = "";
            }

            if (Uploading)
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Imports the model file in the Bdc store.
        /// </summary>
        /// <param name="filePath">Path of the model file.</param>
        /// <param name="packageContents">PackageContents to be imported.</param>
        /// <param name="incrementalUpdate">Flag indicating whether to update the existing model.</param>
        /// <returns>Model object corresponding to the model imported.</returns>
        private Model ImportModelFromFile(string filePath, PackageContents packageContents, bool incrementalUpdate)
        {
            string fileContents;
            using (StreamReader reader = new StreamReader(filePath))
            {
                fileContents = reader.ReadToEnd();
            }

            return ImportModel(fileContents, packageContents, incrementalUpdate);
        }
        /// <summary>
        /// Imports the model contents in the Bdc store.
        /// </summary>
        /// <param name="fileContents">Contents of the Model file.</param>
        /// <param name="packageContents">PackageContents to be imported.</param>
        /// <param name="incrementalUpdate">Flag indicating whether to update the existing model.</param>     
        /// <returns>Model object corresponding to the model imported.</returns>
        private Model ImportModel(string fileContents, PackageContents packageContents, bool incrementalUpdate)
        {
            string[] errors = null;
            Model model = null;

            model = this.amc.ImportPackage(fileContents, out errors, packageContents, null, incrementalUpdate, Guid.NewGuid());

            if (errors != null && errors.Length > 0)
            {
                StringBuilder errorMessage = new StringBuilder();
                //Start with a newline.
                errorMessage.AppendLine();
                foreach (string str in errors)
                {
                    errorMessage.AppendLine(str);
                }

                //Check to see if any of the entities in the model were not activated.
                //Entity.Validate() will return the reason why it happened.
                List<Entity> allEntities = new List<Entity>(model.AllEntities);

                if (allEntities.Count > 0)
                {
                    StringBuilder activationErrors = new StringBuilder();
                    activationErrors.AppendLine();

                    ActivationError[] entityErrors = Entity.Validate(allEntities, this.amc);

                    foreach (ActivationError error in entityErrors)
                    {
                        activationErrors.AppendLine(error.ToString());
                    }

                    if (entityErrors.Length > 0)
                    {
                        throw new ArgumentException(String.Format(CultureInfo.CurrentCulture,
                                "Model file '{0}' has the following External Content Type activation errors:{1}",
                                this.modelFileName, activationErrors.ToString()), "ModelFileName");
                    }
                }
            }
            return model;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Delegate used to submit the element </summary>
        private bool CanSubmit()
        {
            // Typically, this code should never be seen as the publish package dialogs should not
            // be active when there is no authenticator
            if (dynamoViewModel == null || !dynamoViewModel.Model.PackageManagerClient.HasAuthenticator)
            {
                ErrorString = "Your package must contain at least one file.";
                return(false);
            }

            if (Name.Contains(@"\") || Name.Contains(@"/") || Name.Contains(@"*"))
            {
                ErrorString = @"The name of the package cannot contain /,\, or *.";
                return(false);
            }

            if (Name.Length < 3)
            {
                ErrorString = "Name must be at least 3 characters.";
                return(false);
            }

            if (Description.Length <= 10)
            {
                ErrorString = "Description must be longer than 10 characters.";
                return(false);
            }

            if (MajorVersion.Length <= 0)
            {
                ErrorString = "You must provide a Major version as a non-negative integer.";
                return(false);
            }

            if (MinorVersion.Length <= 0)
            {
                ErrorString = "You must provide a Minor version as a non-negative integer.";
                return(false);
            }

            if (BuildVersion.Length <= 0)
            {
                ErrorString = "You must provide a Build version as a non-negative integer.";
                return(false);
            }

            if (Double.Parse(BuildVersion) + Double.Parse(MinorVersion) + Double.Parse(MajorVersion) <= 0)
            {
                ErrorString = "At least one of your version values must be greater than 0.";
                return(false);
            }

            if (!PackageContents.Any())
            {
                ErrorString = "Your package must contain at least one file.";
                return(false);
            }

            if (UploadState != PackageUploadHandle.State.Error)
            {
                ErrorString = "";
            }

            if (Uploading)
            {
                return(false);
            }

            return(true);
        }