예제 #1
0
        public async Task <ActionResult> OnPost()
        {
            if (ModelState.IsValid)
            {
                OrderReceived.OrderId            = (int)OrderNumber;
                OrderReceived.ReceivedTimeString = (new DateTime(OrderReceived.ReceivedTime.Ticks)).ToString("hh:mm");

                await OrderReceivedDataAccess.CreateOrderReceived(OrderReceived);

                Message = new PopUpMessageModel()
                {
                    IsMessageGood = true,
                    Text          = "Order received created successfully"
                };
            }

            var orderId = OrderNumber ?? 0;

            await SetUpProperties(orderId);

            return(Page());
        }
예제 #2
0
        public async Task <ActionResult> OnGet(int?aSpecId, string aMessage, bool?isMessageGood)
        {
            Message = new PopUpMessageModel()
            {
                Text          = aMessage,
                IsMessageGood = isMessageGood
            };

            if (aSpecId != null)
            {
                int tempSpecId = aSpecId ?? default(int); //Converts the int? to an int.  The part after ?? means that if aSpecId == null, then assign a 0 to tempSpecId, but the if() handles null.
                CurrentSpec = await SpecificationDataAccess.GetHydratedCurrentRevOfSpec(tempSpecId);

                CurrentSpecCurrentRev = CurrentSpec.SpecRevModels.OrderByDescending(i => i.InternalRev).FirstOrDefault();
                SpecId            = CurrentSpec.Id;
                SpecInternalRevId = CurrentSpecCurrentRev.InternalRev;

                //ToDo: Get history SPAs for the spec selected.  Populate a history modal or collapsable or something like that
            }
            await SetUpProperties();

            return(Page());
        }
        public async Task <IActionResult> OnGet(int?aSpecId, string aMessage = null, bool?isMessageGood = true)
        {
            if (aMessage != null)
            {
                Message = new PopUpMessageModel()
                {
                    Text          = aMessage,
                    IsMessageGood = isMessageGood
                };
            }

            if (aSpecId != 0 && aSpecId != null)
            {
                if (CurrentSpecId == 0)
                {
                    //?? is a null checker (null coalescing operator).  So if aSpecId is not null, it will be applied to CurrentSpecId.  If it is null (can't happen becuase if statement) CurrentSpecId = 0. This is needed otherwise it will complain that (int != int?).
                    CurrentSpecId = aSpecId ?? 0;
                }
            }

            await SetUpProperties(CurrentSpecId);

            return(Page());
        }
        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());
        }
예제 #5
0
        public async Task <ActionResult> OnPost()
        {
            var optionModels = new List <SpecProcessAssignOptionModel>();

            if (ChoiceId1 != null)
            {
                optionModels.Add(new SpecProcessAssignOptionModel()
                {
                    SpecId        = SpecId,
                    SpecRevId     = SpecInternalRevId,
                    SubLevelSeqId = 1, //TODO: Should this be hard-coded to 1?
                    ChoiceSeqId   = (byte)ChoiceId1
                });
            }

            if (ChoiceId2 != null)
            {
                optionModels.Add(new SpecProcessAssignOptionModel()
                {
                    SpecId        = SpecId,
                    SpecRevId     = SpecInternalRevId,
                    SubLevelSeqId = 2, //TODO: Should this be hard-coded to 2?
                    ChoiceSeqId   = (byte)ChoiceId2
                });
            }

            if (ChoiceId3 != null)
            {
                optionModels.Add(new SpecProcessAssignOptionModel()
                {
                    SpecId        = SpecId,
                    SpecRevId     = SpecInternalRevId,
                    SubLevelSeqId = 3, //TODO: Should this be hard-coded to 3?
                    ChoiceSeqId   = (byte)ChoiceId3
                });
            }

            if (ChoiceId4 != null)
            {
                optionModels.Add(new SpecProcessAssignOptionModel()
                {
                    SpecId        = SpecId,
                    SpecRevId     = SpecInternalRevId,
                    SubLevelSeqId = 4, //TODO: Should this be hard-coded to 4?
                    ChoiceSeqId   = (byte)ChoiceId4
                });
            }

            if (ChoiceId5 != null)
            {
                optionModels.Add(new SpecProcessAssignOptionModel()
                {
                    SpecId        = SpecId,
                    SpecRevId     = SpecInternalRevId,
                    SubLevelSeqId = 5, //TODO: Should this be hard-coded to 5?
                    ChoiceSeqId   = (byte)ChoiceId5
                });
            }

            if (ChoiceId6 != null)
            {
                optionModels.Add(new SpecProcessAssignOptionModel()
                {
                    SpecId        = SpecId,
                    SpecRevId     = SpecInternalRevId,
                    SubLevelSeqId = 6, //TODO: Should this be hard-coded to 6?
                    ChoiceSeqId   = (byte)ChoiceId6
                });
            }

            var theSpecProcessAssignModel = new Armis.BusinessModels.QualityModels.Spec.SpecProcessAssignModel()
            {
                SpecId       = SpecId,
                SpecRevId    = SpecInternalRevId,
                CustomerId   = CustomerId,
                ProcessId    = ProcessId,
                ProcessRevId = ProcessRevId,
                SpecProcessAssignOptionModels = optionModels
            };

            var areChoicesUnique = await SpecProcessAssignDataAccess.VerifyUniqueChoices(SpecId, SpecInternalRevId, CustomerId ?? 0, optionModels);

            if (ModelState.IsValid && areChoicesUnique)
            {
                await SpecProcessAssignDataAccess.PostSpecProcessAssign(theSpecProcessAssignModel);

                return(RedirectToPage("/Quality/Specification/SpecProcessAssign", new { aMessage = "Specification-Process assignment saved successfully", isMessageGood = true }));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    Message = new PopUpMessageModel()
                    {
                        Text          = "Process is required",
                        IsMessageGood = false
                    };

                    await SetUpProperties();

                    return(Page());
                }
                else if (!areChoicesUnique)
                {
                    return(RedirectToPage("/Quality/Specification/SpecProcessAssign", new { aMessage = "Another Specificaiton-Process assignment has already been created with those options", isMessageGood = false }));
                }

                return(RedirectToPage("/Error", new { ExMessage = "An unknown error occured" }));
            }
        }
예제 #6
0
        public async Task <IActionResult> OnPost()
        {
            if (!(await SamplePlanDataAccess.CheckIfNameIsUnique(SamplePlanName)))
            {
                Message = new PopUpMessageModel()
                {
                    IsMessageGood = false,
                    Text          = "A sameple plan with that name already exists."
                };
                return(Page());
            }

            var newSamplePlan = new SamplePlanModel()
            {
                PlanName    = SamplePlanName,
                Description = SamplePlanDescription
            };
            var tempLevelModelList = new List <SamplePlanLevelModel>();

            for (int i = 1; i <= AmountOfLevels; i++)
            {
                var fromValue = int.Parse(HttpContext.Request.Form["inputNumOfPartsFrom" + i]);
                int toValue;
                if (i == AmountOfLevels)
                {
                    toValue = int.MaxValue;
                }
                else
                {
                    toValue = int.Parse(HttpContext.Request.Form["inputNumOfPartsTo" + i]);
                }
                var newSamplePlanLevel = new SamplePlanLevelModel()
                {
                    SamplePlanLevelId = i,
                    FromQty           = fromValue,
                    ToQty             = toValue
                };

                var tempRejectModelList = new List <SamplePlanRejectModel>();

                for (int j = 1; j <= AmountOfTests; j++)
                {
                    var sampleQty  = int.Parse(HttpContext.Request.Form["inputSampleNum" + j + "-" + i]);
                    var rejectQty  = int.Parse(HttpContext.Request.Form["inputRejectNum" + j + "-" + i]);
                    var testTypeId = short.Parse(HttpContext.Request.Form["selectTestType" + j]);

                    var newSamplePlanReject = new SamplePlanRejectModel()
                    {
                        SamplePlanLevelId = i,
                        SampleQty         = sampleQty,
                        RejectAllowQty    = rejectQty,
                        InspectTestTypeId = testTypeId
                    };

                    tempRejectModelList.Add(newSamplePlanReject);
                }

                newSamplePlanLevel.SamplePlanRejectModels = tempRejectModelList;

                tempLevelModelList.Add(newSamplePlanLevel);
            }

            newSamplePlan.SamplePlanLevelModels = tempLevelModelList;

            await SamplePlanDataAccess.CreateNewSamplePlan(newSamplePlan);

            return(RedirectToPage("/Quality/Inspection/SamplePlanEntry", new { aMessage = "Sample Plan created successfully", isMessageGood = true }));
        }