Example #1
0
        public IHttpActionResult PutVtgStaff(int id, VtgStaff vtgStaff)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != vtgStaff.VtgStaffId)
            {
                return(BadRequest());
            }

            db.Entry(vtgStaff).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VtgStaffExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
        public IHttpActionResult PutVisit(int id, VisitViewModel visitVM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var visit = Mapper.Map <VisitViewModel, Visit>(visitVM);

            if (id != visit.VisitId)
            {
                return(BadRequest());
            }
            //Update other related visit Dates
            var study      = db.LinkSubjectsStudies.Find(visitVM.SubjectStudyLinkId);
            var visitOrder = db.VisitSchedules.Where(v => v.StudyId == study.StudyId && v.VisitScheduleId == visitVM.VisitScheduleId).Select(v => v.VisitOrder).FirstOrDefault();


            var relatedSVisits = db.VisitSchedules.Where(v => v.StudyId == study.StudyId && v.VisitOrderThatTimingIsRelativeTo == visitOrder).Select(s => s.VisitScheduleId).ToList();
            var affectedVisits = db.Visits.Where(v => v.SubjectStudyLinkId == visit.SubjectStudyLinkId).Where(l => relatedSVisits.Contains(l.VisitScheduleId.Value)).ToList();

            foreach (var aVisit in affectedVisits)
            {
                aVisit.EarliestDate    = GetEarliestDate(visit.ActualDate, visit.SubjectStudyLinkId, aVisit.VisitScheduleId.Value);
                aVisit.LatestDate      = GetLatestDate(visit.ActualDate, visit.SubjectStudyLinkId, aVisit.VisitScheduleId.Value);
                db.Entry(aVisit).State = EntityState.Modified;
            }


            db.Entry(visit).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VisitExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutLinkDoctorPractice(int id, LinkDoctorPractice linkDoctorPractice)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != linkDoctorPractice.DoctorPracticeLinkId)
            {
                return(BadRequest());
            }

            db.Entry(linkDoctorPractice).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LinkDoctorPracticeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #4
0
        public IHttpActionResult PutTravelReimbursement(int id, TravelReimbursement travelReimbursement)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != travelReimbursement.TravelReimbursementId)
            {
                return(BadRequest());
            }

            db.Entry(travelReimbursement).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TravelReimbursementExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutDoctor(int id, Doctor doctor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != doctor.DoctorId)
            {
                return(BadRequest());
            }

            db.Entry(doctor).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DoctorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #6
0
        public IHttpActionResult PutAppValueListData(int id, AppValueListData appValueListData)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != appValueListData.AppValueListId)
            {
                return(BadRequest());
            }

            db.Entry(appValueListData).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AppValueListDataExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #7
0
        public IHttpActionResult PutVaccination(int id, Vaccination vaccination)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != vaccination.VaccinationId)
            {
                return(BadRequest());
            }
            vaccination.Description     = db.VaccinationTypes.Find(vaccination.TypeVaccinationId).Description;
            db.Entry(vaccination).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VaccinationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #8
0
        public IHttpActionResult PutQuestionnaire(int id, Questionnaire questionnaire)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != questionnaire.QuestionnaireId)
            {
                return(BadRequest());
            }
            questionnaire.Description     = db.QuestionnaireTypes.Find(questionnaire.TypeQuestionnaireId).Description;
            db.Entry(questionnaire).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuestionnaireExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutBodySystem(int id, BodySystem bodySystem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != bodySystem.BodySystemId)
            {
                return(BadRequest());
            }

            db.Entry(bodySystem).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BodySystemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        // PUT: api/ParticipantConsents/5
        //[ResponseType(typeof(void))]
        // [Route("api/ParticipantConsents/{id}")]
        public IHttpActionResult PutParticipantConsent(int id, ParticipantConsent participantConsent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != participantConsent.RowId)
            {
                return(BadRequest());
            }

            db.Entry(participantConsent).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ParticipantConsentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #11
0
        public IHttpActionResult PutStudyConsent(int id, InformedConsentViewModel informedConsent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != informedConsent.InformedConsentId)
            {
                return(BadRequest());
            }

            var consent = Mapper.Map <InformedConsentViewModel, InformedConsent>(informedConsent);

            db.Entry(consent).State = EntityState.Modified;
            db.SaveChanges();



            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutPerson(int id, ParticipantViewModel participant)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != participant.PersonId)
            {
                return(BadRequest());
            }
            var mapper = new ParticipantMapper();
            var person = mapper.GetParticipantModel(participant);

            if (participant.StudyId != 0)
            {
                var linkedStudy = db.LinkSubjectsStudies.Where(l => l.PersonId == participant.PersonId && l.StudyId == participant.StudyId).FirstOrDefault();
                //Study Detail
                linkedStudy.Status = participant.StudyParticipationStatus;
                linkedStudy.OfficialSubjectStudyNum = participant.OfficialSubjectStudyNum;
                linkedStudy.WithdrawnReason         = participant.Reason;
                linkedStudy.WithdrawnReasonOther    = participant.ReasonOther;
                linkedStudy.EffFrom = participant.EffectiveFrom;
                linkedStudy.EffTo   = participant.EffectiveTo;
                linkedStudy.OfficialSubjectStudyNum = participant.OfficialSubjectStudyNum;
                db.Entry(linkedStudy).State         = EntityState.Modified;
            }

            if (participant.HouseholdId.HasValue)
            {
                //Household Detail
                var household = db.Households.Where(h => h.HouseholdId == participant.HouseholdId).FirstOrDefault();
                household.AddressStreet     = participant.Street;
                household.AddressSuburb     = participant.Suburb;
                household.AddressPostcode   = participant.Postcode;
                household.AddressState      = participant.State;
                household.PhoneHome         = participant.PhoneHome;
                household.LastConfirmedBy   = participant.LastConfirmedBy;
                household.LastConfirmedWhen = participant.LastConfirmedWhen;
                household.AddresseeId       = participant.HouseholdAddressee;
                household.ActiveAddress     = participant.ActiveAddress?1:0;
                db.Entry(household).State   = EntityState.Modified;
            }


            db.Entry(person).State = EntityState.Modified;



            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PersonExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }