예제 #1
0
        public UndoDeleteContactDataResponse UndoDeleteContact(UndoDeleteContactDataRequest request)
        {
            UndoDeleteContactDataResponse response = null;

            try
            {
                response = new UndoDeleteContactDataResponse();
                IContactRepository repo = Factory.GetRepository(request, RepositoryType.Contact);
                if (request.Id != null)
                {
                    repo.UndoDelete(request);
                    // Add the deleted contact back into the RecentList of  other contacts(users logged in) who had him/her before the delete action.
                    var undeletedContact = repo.FindByID(request.Id) as ContactData;
                    if (undeletedContact != null)
                    {
                        if (request.ContactWithUpdatedRecentLists != null && request.ContactWithUpdatedRecentLists.Count > 0)
                        {
                            request.ContactWithUpdatedRecentLists.ForEach(c =>
                            {
                                var contactData = repo.FindByID(c.ContactId) as ContactData;
                                if (contactData != null)
                                {
                                    contactData.RecentsList.Insert(c.PatientIndex, undeletedContact.PatientId);
                                    PutRecentPatientRequest recentPatientRequest = new PutRecentPatientRequest
                                    {
                                        ContactId      = c.ContactId,
                                        Context        = request.Context,
                                        ContractNumber = request.ContractNumber,
                                        UserId         = request.UserId,
                                        Version        = request.Version
                                    };
                                    repo.UpdateRecentList(recentPatientRequest, contactData.RecentsList);
                                }
                            });
                        }
                    }
                }
                response.Success = true;
                return(response);
            }
            catch (Exception ex) { throw ex; }
        }
예제 #2
0
        public UndoDeleteContactDataResponse Put(UndoDeleteContactDataRequest request)
        {
            UndoDeleteContactDataResponse response = new UndoDeleteContactDataResponse();

            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    throw new UnauthorizedAccessException("ContactDD:ContactUndoDelete()::Unauthorized Access");
                }

                response         = Manager.UndoDeleteContact(request);
                response.Version = request.Version;
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);

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