示例#1
0
        public async Task <IActionResult> AddSubjects(SubjectRegistrationRequest subRegData)
        {
            _logger.LogInformation($"Invoking endpoint: {this.HttpContext.Request.GetDisplayUrl()}");
            _logger.LogDebug($"Registered subjects - {JsonConvert.SerializeObject(subRegData)}");

            var subject = await _subjectService.AddSubject(subRegData);

            return(Ok(new UniqueIdDetail
            {
                status = subject.status,
                message = subject.message,
                uniqueSubjectId = subject.uniqueSubjectId,
            }));
        }
示例#2
0
        public async Task <UniqueIdDetail> AddSubject(SubjectRegistrationRequest subRegData)
        {
            UniqueIdDetail subRegSuccess = new UniqueIdDetail();

            try
            {
                var result = _subjectData.AddSubject(subRegData);
                subRegSuccess.status          = true;
                subRegSuccess.message         = result.message;
                subRegSuccess.uniqueSubjectId = result.uniqueSubjectId;
            }
            catch (Exception e)
            {
                subRegSuccess.uniqueSubjectId = "";
                subRegSuccess.status          = false;
                subRegSuccess.message         = $"Failed to add subject registration for {subRegData.subjectPrimaryRequest.firstName + " " + subRegData.subjectPrimaryRequest.lastName}";
            }
            return(subRegSuccess);
        }
示例#3
0
        public UniqueIdDetail AddSubject(SubjectRegistrationRequest subRegData)
        {
            var uniqueSubjectId = new UniqueIdDetail();

            try
            {
                SubjectPrimaryDetail subPrimary = subjectPrimary(subRegData.subjectPrimaryRequest);
                if (subPrimary != null)
                {
                    if (subPrimary.id > 0)
                    {
                        var subID       = subPrimary.id;
                        var uniqueSubId = subPrimary.uniqueSubjectId;
                        SubjectAddress(subRegData.subjectAddressRequest, uniqueSubId);
                        SubjectPregnancy(subRegData.subjectPregnancyRequest, uniqueSubId);
                        SubjectParent(subRegData.subjectParentRequest, uniqueSubId);
                        uniqueSubjectId.uniqueSubjectId = uniqueSubId;
                        uniqueSubjectId.message         = "Unique Id Successfully generated";
                        uniqueSubjectId.status          = true;
                    }
                    else
                    {
                        uniqueSubjectId.uniqueSubjectId = "";
                        uniqueSubjectId.status          = false;
                        uniqueSubjectId.message         = $"Failed to add subject registration for {subRegData.subjectPrimaryRequest.firstName + " " + subRegData.subjectPrimaryRequest.lastName}";
                    }
                }
                else
                {
                    uniqueSubjectId.uniqueSubjectId = "";
                    uniqueSubjectId.status          = false;
                    uniqueSubjectId.message         = $"Failed to add subject registration for {subRegData.subjectPrimaryRequest.firstName + " " + subRegData.subjectPrimaryRequest.lastName}";
                }
            }
            catch (Exception e)
            {
                uniqueSubjectId.uniqueSubjectId = "";
                uniqueSubjectId.status          = false;
                uniqueSubjectId.message         = $"Failed to add subject registration for {subRegData.subjectPrimaryRequest.firstName + " " + subRegData.subjectPrimaryRequest.lastName}";
            }
            return(uniqueSubjectId);
        }