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 void GetById_Test() { // Arrange TestKolgraphEntities context = new TestKolgraphEntities(); var repository = new AppointmentTestRepository(context); int id = 1; // Act appointment_test result = repository.GetById(id); // Assert Assert.IsNotNull(result); Assert.AreEqual(id, result.id); }
public int Update(appointment_test entity) { if (entity == null) { return(-1); } using (var context = this._context) { context.MarkAsModified(entity); var result = context.SaveChanges(); return(entity.id); } }
public int Insert(appointment_test entity) { if (entity == null) { return(-1); } using (var context = this._context) { context.appointment_test.Add(entity); var result = context.SaveChanges(); return(entity.id); } }
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); }
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 appointment_test GetById(Int64 id) { using (var context = this._context) { appointment_test entity = context.appointment_test.AsNoTracking() .Include(x => x.test) .Include(x => x.appointment_test_clinician.Select(y => y.employee)) .Include(x => x.room) .Include(x => x.kupah) .Include(x => x.hitchayvut) .Include(x => x.language) .Include(x => x.testResultValueText) .Where(x => x.id == id) .FirstOrDefault(); return(entity); } }
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 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); }
public int Update(AppointmentTestModel model, int userId) { appointment_test entity = this.ConvertModelToEntity(model, userId); return(this._repository.Update(entity)); }
public void MarkAsModified(appointment_test item) { }