Example #1
0
        public string AddCareTeamMember(AddCareTeamMemberDataRequest request)
        {
            var id = string.Empty;

            try
            {
                if (request.CareTeamMemberData != null)
                {
                    using (var ctx = new ContactCareTeamMongoContext(_dbName))
                    {
                        var contactCareTeam = GetContactCareTeam(request.ContactId);

                        if (contactCareTeam == null)
                        {
                            throw new ApplicationException(
                                      "AddCareTeamMember: The referenced contact doesn't have a care team");
                        }

                        if (contactCareTeam.Id != ObjectId.Parse(request.CareTeamId))
                        {
                            throw new ApplicationException(
                                      "AddCareTeamMember: The referenced Care Team doesn't exist or is not assigned to the referenced contact");
                        }

                        var memberToAdd = BuildMECareTeamMember(this.UserId, request.CareTeamMemberData);
                        memberToAdd.RecordCreatedOn = DateTime.UtcNow;
                        memberToAdd.RecordCreatedBy = ObjectId.Parse(request.UserId);

                        contactCareTeam.MeCareTeamMembers.Add(memberToAdd);

                        ctx.CareTeam.Collection.Save(contactCareTeam);

                        AuditHelper.LogDataAudit(this.UserId,
                                                 MongoCollectionName.CareTeam.ToString(),
                                                 contactCareTeam.Id.ToString(),
                                                 DataAuditType.Update,
                                                 request.ContractNumber);


                        id = memberToAdd.Id.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(id);
        }
Example #2
0
        public AddCareTeamMemberDataResponse AddCareTeamMember(AddCareTeamMemberDataRequest request)
        {
            var response = new AddCareTeamMemberDataResponse();

            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            if (request.CareTeamMemberData == null)
            {
                throw new ArgumentNullException("CareTeamMemberData is Null", "request");
            }

            if (string.IsNullOrEmpty(request.ContactId))
            {
                throw new ArgumentNullException("Null or Empty ContactId", "request");
            }

            if (string.IsNullOrEmpty(request.CareTeamId))
            {
                throw new ArgumentNullException("Null or empty CareTeamId", "request");
            }


            var repo = _factory.GetCareTeamRepository(request, RepositoryType.CareTeam);

            if (repo == null)
            {
                throw new Exception("Repository is null");
            }

            try
            {
                //if (repo.CareTeamMemberContactExist(request.CareTeamId, request.CareTeamMemberData.ContactId))
                //    throw new Exception(string.Format("Care Team Member {0} already exists.", request.CareTeamMemberData.ContactId));

                response.Id = repo.AddCareTeamMember(request);
            }
            catch (Exception)
            {
                throw;
            }

            return(response);
        }
Example #3
0
        public AddCareTeamMemberDataResponse Post(AddCareTeamMemberDataRequest request)
        {
            var response = new AddCareTeamMemberDataResponse();

            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    throw new UnauthorizedAccessException("ContactDD:CareTeamService:Post Add Care Team Member::Unauthorized Access");
                }

                response = Manager.AddCareTeamMember(request);
            }
            catch (Exception ex)
            {
                CommonFormat.FormatExceptionResponse(response, base.Response, ex);

                var aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0";
                Helpers.LogException(int.Parse(aseProcessID), ex);
            }
            return(response);
        }