Exemplo n.º 1
0
        public AppointmentTestModel ConvertEntityToModel(appointment_test entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new AppointmentTestModel()
            {
                Id                    = entity.id,
                AppointmentId         = (int)entity.appointmentId,
                ExternalAppointmentId = entity.externalAppointmentId == null ? -1 : (int)entity.externalAppointmentId,
                MachineId             = entity.machineId == null ? -1 : (int)entity.machineId,
                Kupah                 = entity.kupah == null ? null : new KupahModelConcise {
                    Id = entity.kupah.id, Name = entity.kupah.name.Trim()
                },
                Room = entity.room == null ? null : new RoomModel {
                    Id = entity.room.id, Name = entity.room.name.Trim()
                },
                Hitchayvut = entity.hitchayvut == null ? null : _hitchayvutService.ConvertEntityToModel(entity.hitchayvut),
                Language   = entity.language == null ? null : new LanguageModel {
                    Id = entity.language.id, Name = entity.language.name.Trim()
                },
                Test = entity.test == null ? null : new TestModel {
                    Id = entity.test.id, Name = entity.test.name.Trim()
                },
                Notes    = entity.notes,
                NotesRtf = entity.notesRtf,
            };

            return(model);
        }
        public int UpdateTestResultsForAppointmentTest(AppointmentTestModel model, int userId)
        {
            return(-1);

            foreach (var testResultValueMemo in model.TestResultValueTextList)
            {
                //this.Update
            }
        }
Exemplo n.º 3
0
 public IHttpActionResult Post(AppointmentTestModel model, int userId)
 {
     try
     {
         int result = _testResultValueMemoService.InsertTestResultsForAppointmentTest(model, userId);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message.ToString()));
     }
 }
Exemplo n.º 4
0
        public int UpdateTestResultsForAppointmentTest(AppointmentTestModel model, int userId)
        {
            //List<testResultValueText> entityList = new List<testResultValueText>();
            //foreach (var testResultValueText in model.TestResultValueTextList)
            //{
            //    testResultValueText entity = this.ConvertModelToEntity(testResultValueText);
            //    entityList.Add(entity);
            //}
            IEnumerable <testResultValueText> entityList = ConvertModelListToEntityList(model.TestResultValueTextList);
            int result = this._repository.UpdateList(entityList);

            return(result);
        }
Exemplo n.º 5
0
 public IHttpActionResult Post(AppointmentTestModel model, int userId)
 {
     try
     {
         // result will contain the id of the item inserted
         int result = _service.Insert(model, userId);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message.ToString()));
     }
 }
        private AppointmentTestModel GetDemoItem(bool isNew)
        {
            AppointmentTestModel item = new AppointmentTestModel {
                Id = 1, AppointmentId = 1, Test = new TestModel {
                    Id = 1
                }
            };

            if (!isNew)
            {
                item.Id = 1;
            }

            return(item);
        }
        public void ConvertModelToEntity_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var service = new AppointmentTestService();
            AppointmentTestModel model = GetTestModel();

            // Act
            appointment_test entity = service.ConvertModelToEntity(model);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(model.AppointmentId, entity.appointmentId);
            Assert.AreEqual(model.Test.Id, entity.testId);
        }
Exemplo n.º 8
0
        public AppointmentTestModel GetById(int id)
        {
            appointment_test entity = this._repository.GetById(id);

            if (entity == null)
            {
                return(null);
            }

            AppointmentTestModel model = this.ConvertEntityToModel(entity);

            model.EmployeeList            = (List <EmployeeModelConcise>) this.ConvertEntityListToEmployeeModelConciseList(entity.appointment_test_clinician);
            model.TestResultValueTextList = (List <TestResultValueTextModel>) this._testResultValueTextService.ConvertEntityListToModelList(entity.testResultValueText);
            return(model);
        }
        public void GetById_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var repository                 = new AppointmentTestRepository(context);
            var hitchayvutService          = new HitchayvutService();
            var testResultValueTextService = new TestResultValueTextService();
            var service = new AppointmentTestService(repository, hitchayvutService, testResultValueTextService);
            int id      = 1;

            // Act
            AppointmentTestModel result = service.GetById(id);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(id, result.Id);
        }
Exemplo n.º 10
0
        public void Put_Test()
        {
            // Arrange
            var mockServiceText        = new Mock <ITestResultValueTextService>();
            var mockServiceMemo        = new Mock <ITestResultValueMemoService>();
            var controller             = new TestResultController(mockServiceText.Object, mockServiceMemo.Object);
            AppointmentTestModel model = GetDemoItem(false);
            int userId = 1;

            // Act
            IHttpActionResult actionResult = controller.Put(model, userId);
            var contentResult = actionResult as NegotiatedContentResult <AppointmentTestModel>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.AreEqual(HttpStatusCode.Accepted, contentResult.StatusCode);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(model.Id, contentResult.Content.Id);
        }
Exemplo n.º 11
0
        private AppointmentTestModel ConvertEntityToModelConcise(appointment_test entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new AppointmentTestModel()
            {
                Id                    = entity.id,
                AppointmentId         = entity.appointmentId == null ? -1 : (int)entity.appointmentId,
                ExternalAppointmentId = entity.externalAppointmentId == null ? -1 : (int)entity.externalAppointmentId,
                Test                  = entity.test == null ? new TestModel() : new TestModel {
                    Id = entity.test.id, Name = entity.test.name.Trim()
                },
            };

            return(model);
        }
        public void ConvertEntityToModel_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var service             = new AppointmentTestService();
            appointment_test entity = context.appointment_test.Where(x => x.id == 1).FirstOrDefault();

            // Act
            AppointmentTestModel model = service.ConvertEntityToModel(entity);

            // Assert
            Assert.IsNotNull(model);
            Assert.AreEqual(model.Id, entity.id);
            Assert.AreEqual(model.AppointmentId, entity.appointmentId);
            if (entity.test == null)
            {
                Assert.AreEqual(model.Test, null);
            }
            else
            {
                Assert.AreEqual(model.Test.Id, entity.testId);
            }
        }
 public int InsertTestResultsForAppointmentTest(AppointmentTestModel model, int userId)
 {
     return(-1);
 }
Exemplo n.º 14
0
        public IHttpActionResult Put(AppointmentTestModel model, int userId)
        {
            int result = _service.Update(model, userId);

            return(Content(System.Net.HttpStatusCode.Accepted, model));
        }
Exemplo n.º 15
0
        private AppointmentTestModel GetDemoItem(bool isNew)
        {
            AppointmentTestModel item = new AppointmentTestModel
            {
                Id                    = 5,
                AppointmentId         = 1,
                ExternalAppointmentId = -1,
                MachineId             = 0,
                Test                  =
                {
                    Id          =                16,
                    Name        = "acoustic_reflex",
                    DefaultText = null,
                    NumRows     =                 0,
                    NumColumns  =                 0,
                    NumMemos    =                 0,
                    NumCombos   =                 0,
                    HasSummary  = false,
                    IsCurrent   = false
                },
                Room                    = null,
                Language                = null,
                Kupah                   = null,
                Hitchayvut              = null,
                Summary                 = null,
                Notes                   = null,
                NotesRtf                = null,
                EmployeeList            = null,
                TestResultValueTextList = new List <TestResultValueTextModel>
                {
                    new TestResultValueTextModel
                    {
                        Id = 4,
                        AppointmentTestId = 5,
                        Row        = 1,
                        ValueListL = null,
                        ValueListR = new List <string> {
                            "6", "7", "8"
                        },
                        ValueListNoEar = null
                    },
                    new TestResultValueTextModel
                    {
                        Id = 5,
                        AppointmentTestId = 5,
                        Row        = 2,
                        ValueListL = null,
                        ValueListR = new List <string> {
                            "6", "7", "8"
                        },
                        ValueListNoEar = null
                    }
                }
            };

            if (!isNew)
            {
                item.Id = 1;
            }

            return(item);
        }
Exemplo n.º 16
0
        public appointment_test ConvertModelToEntity(AppointmentTestModel model, int userId = -1)
        {
            appointment_test entity = new appointment_test();

            if (model == null)
            {
                return(null);
            }

            entity.appointmentId         = model.AppointmentId;
            entity.externalAppointmentId = model.ExternalAppointmentId;
            entity.machineId             = model.MachineId;
            entity.notes    = model.Notes;
            entity.notesRtf = model.NotesRtf;

            entity.testId = model.Test.Id;

            if (model.Kupah != null)
            {
                if (model.Kupah.Id > 0)
                {
                    entity.kupahId = model.Kupah.Id;
                }
                else
                {
                    entity.kupahId = null;
                }
            }

            if (model.Language != null)
            {
                if (model.Language.Id > 0)
                {
                    entity.languageId = model.Language.Id;
                }
                else
                {
                    entity.languageId = null;
                }
            }

            if (model.Room != null)
            {
                if (model.Room.Id > 0)
                {
                    entity.roomId = model.Room.Id;
                }
                else
                {
                    entity.roomId = null;
                }
            }

            if (model.Hitchayvut != null)
            {
                if (model.Hitchayvut.Id > 0)
                {
                    entity.hitchayvutId = model.Hitchayvut.Id;
                }
                else
                {
                    entity.roomId = null;
                }
            }

            if (model.Id > 0)
            {
                entity.id = model.Id;
            }

            if (userId > 0)
            {
                if (entity.id > 0)
                {
                    entity.editedById   = userId;
                    entity.editedByDate = System.DateTime.Now;
                }
                else //entity.id <= 0
                {
                    entity.createdById   = userId;
                    entity.createdByDate = System.DateTime.Now;
                }
            }

            return(entity);
        }
Exemplo n.º 17
0
        public int Update(AppointmentTestModel model, int userId)
        {
            appointment_test entity = this.ConvertModelToEntity(model, userId);

            return(this._repository.Update(entity));
        }