コード例 #1
0
        public void GlobalHcCap_FuncScoreChange()
        {
            var hci = SimpleGlobal();
            FunctionalityScore fs1 = new FunctionalityScore()
            {
                FunctionalityLevel = new FunctionalityLevel()
                {
                    HcHoursLimit = 200
                },
                StartDate = new DateTime(2000, 1, 1), // starts on second month (Amountreport)
                Client    = hci.Clients.First()
            };

            hci.Clients.First().FunctionalityScores.Add(fs1);
            FunctionalityScore fs2 = new FunctionalityScore()
            {
                FunctionalityLevel = new FunctionalityLevel()
                {
                    HcHoursLimit = 300
                },
                StartDate = new DateTime(2000, 2, 1), // starts on second month (Amountreport)
                Client    = hci.Clients.First()
            };

            hci.Clients.First().FunctionalityScores.Add(fs2);

            // the cap period is from 1/1/200 to 1/3/2000
            var res = ccEntitiesExtensions.GlobalHcCapsQuery(hci.ClientAmountReports.AsQueryable(), hci.MainReports.AsQueryable(), hci.Clients.AsQueryable(), hci.mainID, 20);

            foreach (var r in res)
            {
                var expectedCap1 = (100 * (31M) + (31M) * 200 + (6M + 29M) * 300) / 7;
                Assert.IsTrue(r.Cap == expectedCap1);
            }
        }
コード例 #2
0
        public void HcCap_Test_FuncScoreChange()
        {
            var hci = Simple(); // add new score here affecting only second report
            FunctionalityScore fs = new FunctionalityScore()
            {
                FunctionalityLevel = new FunctionalityLevel()
                {
                    HcHoursLimit = 200
                },
                StartDate = hci.ClientAmountReports[1].ReportDate, // starts on second month (Amountreport)
                Client    = hci.Clients.First()
            };

            hci.Clients.First().FunctionalityScores.Add(fs);
            var res = ccEntitiesExtensions.LocalHcCapsQuery(hci.ClientAmountReports.AsQueryable(), hci.Clients.AsQueryable(), hci.mainID);

            foreach (var r in res)
            {                                                  // here in res i get Cap = 385.71~27 days, 414~29days
                var expectedCap1 = (100 * 31M + 200 * 6M) / 7; // no adding 6 days coz its the last month of eligibility
                // Cap1 returned value is 614.28 no idea why
                var expectedCap2 = 200 * (29M + 6) / 7;        // eligible for 200 weekly hrs // not working
                // cap2 returned value is 828~29 days
                //Assert.IsTrue(r.Cap == expectedCap1 || r.Cap == expectedCap2);
            }
        }
コード例 #3
0
        public ActionResult Delete(int Id)
        {
            if (!this.Permissions.CanDeleteFuncScore)
            {
                throw new InvalidOperationException();
            }

            var toDelete = new FunctionalityScore()
            {
                Id = Id
            };

            Repo.FunctionalityScores.Attach(toDelete);
            Repo.FunctionalityScores.Remove(toDelete);
            try
            {
                Repo.SaveChanges();
            }
            catch
            {
                return(Content("Delete failed"));
            }

            return(Content("ok"));
        }
コード例 #4
0
        public ActionResult Create(FunctionalityScore score)
        {
            if (!this.Permissions.CanUpdateExistingClient)
            {
                throw new InvalidOperationException();
            }

            score = MakeScore(score, db);

            return(View(score));
        }
コード例 #5
0
        public static void AddFuncScore(string FirstName, int dScore, FunctionalityLevel fl)
        {
            ccEntities         context = new ccEntities();
            var                client  = context.Clients.First(x => x.FirstName == FirstName);
            FunctionalityScore fs      = new FunctionalityScore();

            fs.ClientId           = client.Id;
            fs.DiagnosticScore    = dScore;
            fs.FunctionalityLevel = fl;
            fs.UpdatedAt          = DateTime.Now;
            fs.UpdatedBy          = GetAdminUser().Id;
            context.SaveChanges();
        }
コード例 #6
0
        public ActionResult Create(int Id)
        {
            if (!this.Permissions.CanUpdateExistingClient)
            {
                throw new InvalidOperationException();
            }

            var model = new FunctionalityScore()
            {
                ClientId = Id
            };

            return(View(model));
        }
コード例 #7
0
        public void RemoveObject(Daf entity)
        {
            var d = sdf(DateTime.Now, this.Permissions.User.Id)(entity);

            if (entity.FunctionalityScoreId.HasValue)
            {
                var fs = new FunctionalityScore {
                    Id = entity.FunctionalityScoreId.Value
                };
                db.FunctionalityScores.Attach(fs);
                db.FunctionalityScores.DeleteObject(fs);
            }
            db.DafDeleteds.AddObject(d);
            db.Dafs.DeleteObject(entity);
        }
コード例 #8
0
ファイル: ScoreData.cs プロジェクト: voidALPHA/cgc_viz
        public AvailabilityScore()
        {
            Performance = new PerformanceScore();

            Functionality = new FunctionalityScore();
        }
コード例 #9
0
        public FunctionalityScore MakeScore(FunctionalityScore score, ccEntities db)
        {
            db.ContextOptions.LazyLoadingEnabled   = false;
            db.ContextOptions.ProxyCreationEnabled = false;

            ViewBag.Success = false;

            ModelState.Clear();

            var functiolnalityLevel = FunctionalityLevel.GetLevelByScore(db.FunctionalityLevels, score);

            if (functiolnalityLevel != null)
            {
                score.FunctionalityLevelId = functiolnalityLevel.Id;
            }

            var client = db.Clients.SingleOrDefault(f => f.Id == score.ClientId);

            if (score.StartDate < client.JoinDate)
            {
                ModelState.AddModelError(string.Empty, "Start Date cannot be earlier than client's join date.");
            }

            var existing = db.FunctionalityScores.Any(f => f.StartDate == score.StartDate && f.ClientId == score.ClientId);

            if (existing)
            {
                ModelState.AddModelError(string.Empty,
                                         "Duplicate functionality scores are not allowed"
                                         );
            }



            var lastReport = ccEntitiesExtensions.LastSubmittedHcRepDate(score.ClientId);

            if (this.Permissions.User.RoleId != (int)FixedRoles.Admin && score.StartDate < lastReport)
            {
                ModelState.AddModelError(string.Empty, "Start date cannot be within an already submitted Financial Report period.");
            }

            TryValidateModel(score);

            if (ModelState.IsValid)
            {
                try
                {
                    score.UpdatedAt = DateTime.Now;
                    score.UpdatedBy = this.Permissions.User.Id;


                    db.FunctionalityScores.AddObject(score);

                    var rowsUpdated = db.SaveChanges();
                    if (rowsUpdated > 0)
                    {
                        score = new FunctionalityScore();
                    }
                    ViewBag.Success = true;
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError(ex.GetType().ToString(), ex);
                }
                catch (UpdateException ex)
                {
                    ModelState.AddModelError(ex.GetType().ToString(), ex);
                    ModelState.AddModelError(string.Empty, ex.InnerException.Message);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                }
            }
            return(score);
        }