コード例 #1
0
        public HttpResponseMessage SavePatient([FromBody] PatientEnitities patientForInsert)
        {
            int result = 0;
            HttpResponseMessage httpResponseMessage;

            if (patientForInsert == null)
            {
                httpResponseMessage         = new HttpResponseMessage(HttpStatusCode.BadRequest);
                httpResponseMessage.Content = new ObjectContent(typeof(string), "Bad Request Received", GlobalConfiguration.Configuration.Formatters.JsonFormatter);
                return(httpResponseMessage);
            }
            try
            {
                result = _patientServices.CreatePatient(patientForInsert);
                if (result != 0)
                {
                    httpResponseMessage         = new HttpResponseMessage(HttpStatusCode.Created);
                    httpResponseMessage.Content = new ObjectContent(typeof(string), "New Patient Record Created", GlobalConfiguration.Configuration.Formatters.JsonFormatter);
                    return(httpResponseMessage);
                }
                else
                {
                    httpResponseMessage         = new HttpResponseMessage(HttpStatusCode.InternalServerError);
                    httpResponseMessage.Content = new ObjectContent(typeof(string), "An error occured while creating patient", GlobalConfiguration.Configuration.Formatters.JsonFormatter);
                    return(httpResponseMessage);
                }
            }
            catch (Exception ex)
            {
                httpResponseMessage         = new HttpResponseMessage(HttpStatusCode.InternalServerError);
                httpResponseMessage.Content = new ObjectContent(typeof(string), "An error occured while creating patient", GlobalConfiguration.Configuration.Formatters.JsonFormatter);
                return(httpResponseMessage);
            }
        }
コード例 #2
0
        public void AddNewpatientTestWithNull()
        {
            PatientEnitities patientEnitities = new PatientEnitities();

            patientEnitities = null;
            Assert.AreEqual(_patientService.CreatePatient(patientEnitities), 0);
        }
コード例 #3
0
        public List <PatientEnitities> getPatientList()
        {
            List <PatientEnitities> lstPatientEnitities = new List <PatientEnitities>();

            try
            {
                WebConfigPropertyService webConfigPropertyService = new WebConfigPropertyService();
                using (var httpClient = new HttpClient())
                {
                    httpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
                    Uri uri      = new Uri(string.Concat(ConfigurationManager.AppSettings[AppSettings.key_Url_WebApi_BaseAddress], ConfigurationManager.AppSettings[AppSettings.key_Url_Reource_WebApi_getAllPatient]));
                    var response = httpClient.GetStringAsync(uri).Result;
                    if (Response.StatusDescription == HttpStatusCode.OK.ToString())
                    {
                        var releases = JArray.Parse(response);
                        List <JsonPatientList> myDeserializedObjList = (List <JsonPatientList>)Newtonsoft.Json.JsonConvert.DeserializeObject(response, typeof(List <JsonPatientList>));
                        foreach (var item in myDeserializedObjList)
                        {
                            PatientEnitities PatientEnitities = ObjectConverter.XMLToObject <PatientEnitities>(item.PatientData);
                            lstPatientEnitities.Add(PatientEnitities);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(lstPatientEnitities);
        }
コード例 #4
0
        public void AddNewpatientTest()
        {
            PatientEnitities patientEnitities = new PatientEnitities()
            {
                ForeName       = "testForeName",
                SurName        = "testSurName",
                Gender         = "testGender",
                DOB            = DateTime.Now.ToShortDateString(),
                contactDetails = new ContactDetails()
                {
                    Home   = new List <string>(),
                    Mobile = new List <string>(),
                    Work   = new List <string>()
                }
            };

            Assert.AreNotEqual(_patientService.CreatePatient(patientEnitities), 0);
        }
コード例 #5
0
 /// <summary>
 /// Method to create Patient entry in db
 /// </summary>
 /// <param name="PatientEntity"></param>
 /// <returns></returns>
 public int CreatePatient(PatientEnitities patientEntity)
 {
     if (patientEntity != null)
     {
         using (var scope = new TransactionScope())
         {
             var patients = new PatientDetail
             {
                 PatientData = Utility.ObjectConverter.ObjectToXMLGeneric <PatientEnitities>(patientEntity),
                 Created     = DateTime.Now
             };
             _unitOfWork.PatientRepository.Insert(patients);
             _unitOfWork.Save();
             scope.Complete();
             return(1);
         }
     }
     return(0);
 }