Exemplo n.º 1
0
        public static StudyEnrolment ToAppModel(ServiceData.Models.StudyEnrolment given, bool includeStudy, bool includeUser)
        {
            if (given == null)
            {
                return(null);
            }

            StudyEnrolment appEnrolment = new StudyEnrolment
            {
                Id        = given.Id,
                CreatedAt = given.CreatedAt,
                StudyId   = given.StudyId,
                UserId    = given.UserId,
                Enrolled  = given.Enrolled
            };

            if (given.Study != null && includeStudy)
            {
                appEnrolment.Study = Study.ToAppModel(given.Study, true);
            }

            if (given.User != null && includeUser)
            {
                appEnrolment.User = User.ToAppModel(given.User);
            }

            return(appEnrolment);
        }
Exemplo n.º 2
0
        public async Task <HttpResponseMessage> Delete(int studyId)
        {
            ServiceData.Models.StudyEnrolment found = _studyEnrolmentRepository.Search(
                en => en.User.Email == User.Identity.Name &&
                en.StudyId == studyId
                ).FirstOrDefault();

            if (found != null)
            {
                await _studyEnrolmentRepository.Delete(found.Id);
            }

            ServerUtils.LogTelemetryEvent(User.Identity.Name, "DeleteShare");
            return(Request.CreateResponse(HttpStatusCode.OK));
        }