//private string ConnectionString;
        //private daDescriptionListing DAL;


        #region "Get Methods"

        public SpecModel GetSpecbySerialNumber(string SerialNumber)
        {
            SpecModel model = new SpecModel();

            if (SerialNumber == "100085")
            {
                model.SpecCollection.Add(new SpecModel.tblSpec {
                    SpecID = 1, ModelID = 1, SpecName = "I0550N27B"
                });
            }

            else if (SerialNumber == "100086")
            {
                model.SpecCollection.Add(new SpecModel.tblSpec {
                    SpecID = 2, ModelID = 1, SpecName = "I0550N28B"
                });
            }
            else if (SerialNumber == "100087")
            {
                model.SpecCollection.Add(new SpecModel.tblSpec {
                    SpecID = 3, ModelID = 2, SpecName = "I0220N28B"
                });
            }
            else if (SerialNumber == "100088")
            {
                model.SpecCollection.Add(new SpecModel.tblSpec {
                    SpecID = 4, ModelID = 1, SpecName = "I0550N29B"
                });
            }

            return(model);
        }
        public SpecModel GetSpecModel(int?SpecID)
        {
            SpecModel model = new SpecModel();

            //UNCOMMENT WHEN DAL SET UP
            //DataTable dtSpec = DAL.GetSpecModel(ConnectionString);

            //foreach (DataRow row in dtSpec.Rows)
            //{
            //    model.SpecCollection.Add(new SpecModel.tblSpec
            //    {
            //        SpecID = Convert.ToInt32(row["SpecID"]),
            //        ModelID = Convert.ToInt32(row["ModelID"]),
            //        SpecName = row["SpecName"].ToString()
            //    });

            //COMMENT REGION WHEN DAL SET UP
            #region Spec unit test values
            model.SpecCollection.Add(new SpecModel.tblSpec {
                SpecID = 1, ModelID = 1, SpecName = "I0550N27B"
            });
            model.SpecCollection.Add(new SpecModel.tblSpec {
                SpecID = 2, ModelID = 1, SpecName = "I0550N28B"
            });
            model.SpecCollection.Add(new SpecModel.tblSpec {
                SpecID = 3, ModelID = 2, SpecName = "I0220N28B"
            });
            model.SpecCollection.Add(new SpecModel.tblSpec {
                SpecID = 4, ModelID = 1, SpecName = "I0550N29B"
            });
            #endregion
            model.SpecCollection.RemoveAll(item => (item.SpecID != SpecID && SpecID != null));
            return(model);
        }
Exemple #3
0
 public static Specification ToEntity(this SpecModel aSpecModel, int aSpecId) //A spec Id needs to be passed in because it won't be known until the service level of the API.
 {
     return(new Specification
     {
         SpecId = aSpecId,
         SpecCode = aSpecModel.Code
     });
 }
        public SpecModel FindSpecModelByEngineModel(int modelID)
        {
            SpecModel model = GetSpecModel();

            model.SpecCollection.RemoveAll(item => item.ModelID != modelID);

            return(model);
        }
Exemple #5
0
        protected void btnAddSpec_OnClick(object sender, EventArgs e)
        {
            var model = new SpecModel();

            specCategoryControl.Model = model;
            specDataControl.Model     = model;

            rbType.TrySetSelectedValue("Category");

            mpeAddEditSpec.Show();
        }
        public SpecCategoryDescriptionViewModel()
        {
            CategoryViewModel    = new CategoryModel();
            DescriptionViewModel = new DescriptionModel();
            SpecViewModel        = new SpecModel();
            PositionViewModel    = new PositionModel();
            StatusViewModel      = new StatusModel();

            CategoryDescriptionCollection = new List <tblCategoryDescription>();
            DDLSelectIDs = new List <int>();

            dict = new Dictionary <string, List <SelectListItem> >();
        }
Exemple #7
0
        public async Task <ActionResult <int> > CreateNewSpec(SpecModel aSpecModel)
        {
            try
            {
                var data = await SpecService.CreateNewSpec(aSpecModel);

                return(Ok(JsonSerializer.Serialize(data)));
            }
            catch (Exception ex)
            {
                _logger.LogError("SpecController.CreateNewSpec(SpecModel aSpecModel) Not able to create new spec ({spec}). | Message: {exMessage} | StackTrace: {stackTrace}", JsonSerializer.Serialize(aSpecModel), ex.Message, ex.StackTrace);
                return(BadRequest(ex.Message));
            }
        }
        public List <SelectListItem> GetSpecSelectList(SpecModel model)
        {
            List <SelectListItem> SpecList = new List <SelectListItem>();

            foreach (var item in model.SpecCollection)
            {
                SpecList.Add(new SelectListItem()
                {
                    Text  = item.SpecName,
                    Value = item.SpecID.ToString(),
                });
            }
            return(SpecList);
        }
        public static IList <DataModel> DoScale(SpecModel specModel, string lang)
        {
            var dataModels = new List <DataModel>();
            var scales     = new int[] { 1, 10, 100 };

            foreach (var scale in scales)
            {
                dataModels.Add(new DataModel()
                {
                    Text  = ComposeText(specModel.Input, lang, scale),
                    Lang  = lang,
                    Scale = $"x{scale}",
                    Type  = specModel.TypeName
                });
            }
            return(dataModels);
        }
Exemple #10
0
        public SpecificationForm(int ID)
        {
            InitializeComponent();

            // Defines the progressbar and submit button to allow the progressbar methods to work in the FormUserControl(base)
            progressBar  = prog;
            submitButton = btnSubmit;

            _specRepo = new SpecificationRepository();

            SpecModel = _specRepo.Get(ID);

            _updatingPage = !SpecModel.IsNew();

            PrepareUpdate();

            DataContext = this;
        }
Exemple #11
0
        public static IShipmentSpec ToSpec(this SpecModel model)
        {
            var t = typeof(SpecModelExtensions)
                    .Assembly
                    .GetImplementations <IShipmentSpec>()
                    .First(x => x.Name == model.Name);

            var instance = Activator.CreateInstance(t);

            foreach (var c in model.Criteria)
            {
                var property = t.GetProperty(c.Name);
                var setter   = property.GetSetMethod();
                setter.Invoke(instance, new[] {
                    ConvertTo(c.Value, property.PropertyType)
                });
            }
            return(instance as IShipmentSpec);
        }
Exemple #12
0
        protected void specTreeControl_OnAddChild(object sender, GenericEventArgs <Guid> e)
        {
            var entity = DataContext.LP_Specs.FirstOrDefault(n => n.ID == e.Value);

            if (entity == null)
            {
                return;
            }

            var model = new SpecModel();

            model.ParentID = entity.ID;

            specCategoryControl.Model = model;
            specDataControl.Model     = model;

            rbType.TrySetSelectedValue("Category");

            mpeAddEditSpec.Show();
        }
 public SerialNumberEngineModelSpec()
 {
     EngineModelViewModel  = new EngineModelModel();
     SpecViewModel         = new SpecModel();
     SerialNumberViewModel = new SerialNumberModel();
 }
Exemple #14
0
        public async Task <int> CreateNewSpec(SpecModel aSpecModel)
        {
            using (var transaction = await context.Database.BeginTransactionAsync())
            {
                var theNewSpecId = await context.Specification.MaxAsync(i => i.SpecId) + 1;

                short theNewRevId = 10; //All new specs start with a revId of 10
                if (aSpecModel.SpecRevModels == null)
                {
                    throw new Exception("Cannot create a new Specification without a Revision.");
                }
                if (aSpecModel.SpecRevModels.Count() > 1)
                {
                    throw new Exception("Cannot save a new Specification with multiple revisions; only one revision is allowed.");
                }
                var theSpecRevModel     = aSpecModel.SpecRevModels.FirstOrDefault(); //Only ONE revision can be passed in.
                var theSubLevelEntities = theSpecRevModel.SubLevels.ToEntities(theNewSpecId, theNewRevId);

                await context.Specification.AddAsync(aSpecModel.ToEntity(theNewSpecId));

                await context.SpecificationRevision.AddAsync(theSpecRevModel.ToEntity(theNewSpecId, theNewRevId));

                await context.SpecSubLevel.AddRangeAsync(theSubLevelEntities);

                foreach (var subLevel in theSpecRevModel.SubLevels)
                {
                    var choicesToAdd = subLevel.Choices.ToEntities(theNewSpecId, theNewRevId).ToList();
                    foreach (var choice in choicesToAdd)
                    {
                        choice.OnlyValidForChoice = null;
                    }
                    await context.AddRangeAsync(choicesToAdd); //Problem is here and it happens immediatly!!! <--- TODO?
                }

                await context.SaveChangesAsync();

                //Updating entities with dependents
                foreach (var subLevel in theSpecRevModel.SubLevels)
                {
                    var originalChoices = subLevel.Choices.ToList();
                    var choicesToUpdate = await context.SpecChoice.Where(i => i.SpecId == theNewSpecId && i.SpecRevId == theNewRevId && i.SubLevelSeqId == subLevel.LevelSeq).ToListAsync();

                    foreach (var choice in choicesToUpdate)
                    {
                        choice.OnlyValidForChoice = originalChoices.FirstOrDefault(i => i.ChoiceSeqId == choice.ChoiceSeqId).OnlyValidForChoiceId;
                    }

                    context.UpdateRange(choicesToUpdate);
                    await context.SaveChangesAsync();
                }


                //Default choice in the subLevel has to be null when saving the data for the first time to prevent an issue with circular dependency.  They must be updated after the first save.
                foreach (var subLevel in theSubLevelEntities)
                {
                    subLevel.DefaultChoice = theSpecRevModel.SubLevels.FirstOrDefault(i => i.LevelSeq == subLevel.SubLevelSeqId).DefaultChoice;
                }

                context.UpdateRange(theSubLevelEntities);

                await context.SaveChangesAsync();

                await transaction.CommitAsync();

                return(theNewSpecId);
            }
        }
        public async Task <ActionResult> OnPost()
        {
            Message = new PopUpMessageModel();

            if (!ModelState.IsValid) //ToDo: Is this even used?
            {
                Message.Text          = ModelState.ToString();
                Message.IsMessageGood = false;

                return(Page());
            }

            if (!(await SpecDataAccess.CheckIfCodeIsUnique(SpecCode)) && CurrentSpecId == 0)
            {
                Message = new PopUpMessageModel()
                {
                    IsMessageGood = false,
                    Text          = "A specification with that code already exists"
                };

                await SetUpProperties(CurrentSpecId);

                return(Page());
            }

            var theSpec = new SpecModel()
            {
                Id   = CurrentSpecId,
                Code = SpecCode
            };

            var theSpecRev = new SpecRevModel()
            {
                //Date & Time Modified will be set at the API level.
                SpecId         = CurrentSpecId,
                Description    = SpecDescription,
                ExternalRev    = ExternalRev,
                EmployeeNumber = 941,
                SamplePlanId   = SamplePlanId
            };

            var theSubLevelList = new List <SpecSubLevelModel>(); //This will be assigned to theSpec.Sublevels at the end.

            byte subLevelSeq = 0;

            //Sublevel 1
            if (SubLevelName1 != null)
            {
                subLevelSeq++;
                theSubLevelList.Add(BuildSubLevelFromPage(subLevelSeq, SubLevelName1, ChoiceList1, IsSubLevelReq1, DefaultChoice1));
            }

            //Sublevel 2
            if (SubLevelName2 != null)
            {
                subLevelSeq++;
                theSubLevelList.Add(BuildSubLevelFromPage(subLevelSeq, SubLevelName2, ChoiceList2, IsSubLevelReq2, DefaultChoice2));
            }

            //Sublevel 3
            if (SubLevelName3 != null)
            {
                subLevelSeq++;
                theSubLevelList.Add(BuildSubLevelFromPage(subLevelSeq, SubLevelName3, ChoiceList3, IsSubLevelReq3, DefaultChoice3));
            }

            //Sublevel 4
            if (SubLevelName4 != null)
            {
                subLevelSeq++;
                theSubLevelList.Add(BuildSubLevelFromPage(subLevelSeq, SubLevelName4, ChoiceList4, IsSubLevelReq4, DefaultChoice4));
            }

            //Sublevel 5
            if (SubLevelName5 != null)
            {
                subLevelSeq++;
                theSubLevelList.Add(BuildSubLevelFromPage(subLevelSeq, SubLevelName5, ChoiceList5, IsSubLevelReq5, DefaultChoice5));
            }

            //Sublevel 6
            if (SubLevelName6 != null)
            {
                subLevelSeq++;
                theSubLevelList.Add(BuildSubLevelFromPage(subLevelSeq, SubLevelName6, ChoiceList6, IsSubLevelReq6, DefaultChoice6));
            }


            theSpecRev.SubLevels = theSubLevelList;
            var theSpecRevsTempList = new List <SpecRevModel>();

            theSpecRevsTempList.Add(theSpecRev); //This is just a list of one to hold the rev because Specification Model takes a list of revs, not just one.
            theSpec.SpecRevModels = theSpecRevsTempList;
            var theReturnedSpecId = 0;           //This is the SpecId that will be returned from the DataAccess after creating a new Spec or Reving up a Spec.

            if (CurrentSpecId == 0)              //New Spec
            {
                theReturnedSpecId = await SpecDataAccess.CreateNewHydratedSpec(theSpec);

                CurrentSpecId         = theReturnedSpecId;
                Message.Text          = "Spec created successfully.";
                Message.IsMessageGood = true;
            }
            else if (WasRevUpSelected) //Spec is being Reved-Up.
            {
                theSpec.Id        = CurrentSpecId;
                theReturnedSpecId = await SpecDataAccess.RevUpSpec(theSpecRev);

                Message.Text          = "Spec reved-up successfully";
                Message.IsMessageGood = true;
            }
            await SetUpProperties(theReturnedSpecId);

            return(Page());
        }
Exemple #16
0
 public async Task <int> CreateNewHydratedSpec(SpecModel aSpecModel)
 {
     return(await DataAccessGeneric.HttpPostRequest <int, SpecModel>(Config["APIAddress"] + "api/spec/CreateNewSpec", aSpecModel, _httpContextAccessor.HttpContext));
 }
 public void UpdateSpecModel(SpecModel model)
 {
     //Invoke DAL method to delete row in tblEngineModel
 }
 public void AddSpec(SpecModel SpecModel)
 {
 }
Exemple #19
0
 public ModelSpec()
 {
     EngineViewModel = new EngineModelModel();
     SpecViewModel   = new SpecModel();
 }