Ejemplo n.º 1
0
        static void Linq43()
        {
            var customers = GetCustomerList();

            var customerOrderGroups = customers
                                      .Select(c => new
            {
                c.CompanyName,
                YearGroups =
                    (
                        c.Orders
                        .GroupBy(y => y.OrderDate.Year)
                        .Select(YearGroup => new
                {
                    Year = YearGroup.Key,
                    MonthGroups =
                        (
                            YearGroup
                            .GroupBy(m => m.OrderDate.Month)
                            .Select(MonthGroup => new
                    {
                        Month = MonthGroup.Key, Orders = MonthGroup
                    })

                        )
                })
                    )
            });

            ObjectDumper.Write(customerOrderGroups, 3);
        }
Ejemplo n.º 2
0
        public IHttpActionResult CreateYearGroup(YearGroup yearGroup)
        {
            if (!ModelState.IsValid)
            {
                return(Content(HttpStatusCode.BadRequest, "Invalid data"));
            }

            _context.YearGroups.Add(yearGroup);
            return(Ok("Year group added"));
        }
Ejemplo n.º 3
0
        private void LoadFromModel(YearGroup model)
        {
            StudentGroupId        = model.StudentGroupId;
            CurriculumYearGroupId = model.CurriculumYearGroupId;

            if (model.StudentGroup != null)
            {
                StudentGroup = new StudentGroupModel(model.StudentGroup);
            }

            if (model.CurriculumYearGroup != null)
            {
                CurriculumYearGroup = new CurriculumYearGroupModel(model.CurriculumYearGroup);
            }
        }
        public async Task ShouldRequestAnItemFromTheApi()
        {
            var client = Mock.Of <ApiClient>();

            var item = new YearGroup();

            int itemId = 1;

            Mock.Get(client).Setup(c => c.GetObject <YearGroup>(
                                       $"{YearGroupsResource.ResourceName}/{itemId}",
                                       It.IsAny <ExpandoObject>())).Returns(Task.FromResult(item)).Verifiable();

            var yearGroupResource = new YearGroupsResource(client);
            var result            = await yearGroupResource.Find(itemId);

            Mock.Get(client).VerifyAll();
        }
Ejemplo n.º 5
0
        //Clinic boundClinic = null;

        void Awake()
        {
            unitRenderer.SetColors(Color.black);

            Inventory = new Inventory(this);
            //YearHolder yearHolder = new YearHolder (500, 0);
            YearGroup years = new YearGroup(0, 500);

            years.onEmpty += OnDeliverYears;
            //yearHolder.HolderEmptied += OnDeliverYears;
            //yearHolder.DisplaySettings = new ItemHolderDisplaySettings (true, false);

            //Inventory.Add (yearHolder);
            Inventory.Add(years);

            //PerformableActions = new PerformableActions (this);

            /*PerformableActions.Add (new DeliverUnpairedItem<ElderHolder> ());
             * PerformableActions.Add (new DeliverAllYears ());
             * PerformableActions.Add (new ConsumeItem<YearHolder> ());*/
        }
Ejemplo n.º 6
0
        public IHttpActionResult UpdateYearGroup(YearGroup yearGroup)
        {
            if (!ModelState.IsValid)
            {
                return(Content(HttpStatusCode.BadRequest, "Invalid data"));
            }

            var yearGroupInDb = _context.YearGroups.SingleOrDefault(x => x.Id == yearGroup.Id);

            if (yearGroupInDb == null)
            {
                return(Content(HttpStatusCode.NotFound, "Year group not found"));
            }

            yearGroupInDb.Name   = yearGroup.Name;
            yearGroupInDb.HeadId = yearGroup.HeadId;

            _context.SaveChanges();

            return(Ok("Year group updated"));
        }
Ejemplo n.º 7
0
        public static DataPackage AddSchoolIntake(
            this DataPackage dataPackage,
            Guid schoolIntakeId,
            string admissionYear,
            string admissionTerm,
            YearGroup yearGroup,
            int numberOfPlannedAdmission,
            string admissionGroupName,
            DateTime dateOfAdmission,
            int capacity,
            Guid?admissionGroupId   = null,
            int?tenantId            = null,
            string schoolInTakeName = null)
        {
            tenantId = tenantId ?? Environment.Settings.TenantId;
            dataPackage.AddData("SchoolIntake", new
            {
                Id                     = schoolIntakeId,
                School                 = CoreQueries.GetSchoolId(),
                Name                   = schoolInTakeName ?? admissionYear + " - " + admissionTerm + " " + yearGroup.FullName,
                YearOfAdmission        = Queries.GetAdmissionYear(admissionYear).ID,
                AdmissionTerm          = CoreQueries.GetLookupItem("AdmissionTerm", code: admissionTerm),
                YearGroup              = yearGroup.ID,
                PlannedAdmissionNumber = numberOfPlannedAdmission,
                IsActive               = true,
                TenantID               = tenantId
            })
            .AddData("AdmissionGroup", new
            {
                Id              = admissionGroupId ?? Guid.NewGuid(),
                Name            = admissionGroupName,
                SchoolIntake    = schoolIntakeId,
                DateOfAdmission = dateOfAdmission,
                Capacity        = capacity,
                IsActive        = true,
                TenantID        = tenantId
            });

            return(dataPackage);
        }
        public async Task YearGroupFetchesStudents()
        {
            IList <Student> groups = new List <Student>()
            {
                new Student(), new Student()
            };

            var client = Mock.Of <ApiClient>();

            var resource = new YearGroupsResource(client);

            var yearGroup = new YearGroup();

            yearGroup.Resource = resource;

            var resourceAddress = $"{YearGroupsResource.ResourceName}/{yearGroup.Code}/students";

            Mock.Get(client).Setup(c => c.GetList <Student>(resourceAddress, It.IsAny <ExpandoObject>())).Returns(Task.FromResult(groups));

            var results = await yearGroup.Students();

            Assert.That(results.First().FirstName, Is.EqualTo(groups.First().FirstName));
        }
Ejemplo n.º 9
0
 public YearGroupModel(YearGroup model) : base(model)
 {
     LoadFromModel(model);
 }