public IHttpActionResult Delete(int id, int studentId)
        {
            var classModel = new StandAloneEvent(id)
            {
                ActualStudents = new User(studentId).PutIntoList()
            };
            var result = PerformAction <RemoveStudentFromEvent, Event>(new RemoveStudentFromEvent(classModel));

            return(new ActionResultToOkHttpActionResult <Event, EventModel>(result, x => x.ToModel(), this)
                   .Do());
        }
        public IHttpActionResult Post(int id, int studentId)
        {
            var classModel = new StandAloneEvent(id)
            {
                Id             = id,
                ActualStudents = new User(studentId).PutIntoList()
            };
            var result = PerformAction <CheckStudentIntoEvent, Event>(new CheckStudentIntoEvent(classModel));

            return(new ActionResultToOkHttpActionResult <Event, EventModel>(result, x => x.ToModel(), this)
                   .Do());
        }
Exemplo n.º 3
0
        private static StandAloneEventModel ToStripedModel(this StandAloneEvent instance)
        {
            if (instance.IsNull())
            {
                return(null);
            }

            return(new StandAloneEventModel
            {
                Price = instance.Price,
                IsPrivate = instance.IsPrivate,
                ClassCapacity = instance.ClassCapacity
            });
        }
Exemplo n.º 4
0
        private static StandAloneEventModel ToModel(this StandAloneEvent instance)
        {
            if (instance.IsNull())
            {
                return(null);
            }

            return(new StandAloneEventModel
            {
                Id = instance.Id,
                Teachers = instance.Teachers.SelectIfNotNull(x => x.ToStripedModel()).ToListIfNotNull(),
                Name = instance.Name,
                EndTime = instance.EndTime,
                StartTime = instance.StartTime,
                Room = instance.Room.ToStripedModel(),
                Price = instance.Price,
                IsPrivate = instance.IsPrivate,
                TeacherRate = instance.TeacherRate
            });
        }
Exemplo n.º 5
0
        public static EventForRegistrationModel ToEventForRegistrationModel(this StandAloneEvent instance, int userId)
        {
            if (instance.IsNull())
            {
                return(null);
            }

            return(new EventForRegistrationModel
            {
                Id = instance.Id,
                Name = instance.Name,
                EndTime = instance.EndTime,
                StartTime = instance.StartTime,
                ClassCapacity = instance.ClassCapacity,
                Price = instance.Price,
                IsPrivate = instance.IsPrivate,
                IsAlreadyRegistered = instance.RegisteredStudents.Any(x => x.Id == userId),
                SpacesAvailable = instance.ClassCapacity - instance.RegisteredStudents.Count
            });
        }