public AppointmentTestEmployeeModel GetById(int id) { appointment_test_clinician entity = this._repository.GetById(id); AppointmentTestEmployeeModel model = this.ConvertEntityToModel(entity); return(model); }
public appointment_test_clinician ConvertModelToEntity(AppointmentTestEmployeeModel model, int userId = -1) { appointment_test_clinician entity = new appointment_test_clinician(); if (model == null) { return(null); } entity.appointmentTestId = model.AppointmentTestId; entity.clinicianId = model.Employee.Id; entity.clinicianName = model.Employee.Name; 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 Insert(int appointmentTestId, int employeeId, string employeeName, int userId) { AppointmentTestEmployeeModel model = new AppointmentTestEmployeeModel { Id = -1, AppointmentTestId = appointmentTestId, Employee = new EmployeeModelConcise { Id = employeeId, Name = employeeName } }; appointment_test_clinician entity = this.ConvertModelToEntity(model, userId); return(this._repository.Insert(entity)); }
public appointment_test_clinician GetById(Int64 id) { using (var context = this._context) { appointment_test_clinician entity = context.appointment_test_clinician.AsNoTracking() .Include(x => x.employee) .Where(x => x.id == id) .FirstOrDefault(); return(entity); } }
public void GetById_Test() { // Arrange TestKolgraphEntities context = new TestKolgraphEntities(); var repository = new AppointmentTestEmployeeRepository(context); int id = 1; // Act appointment_test_clinician result = repository.GetById(id); // Assert Assert.IsNotNull(result); Assert.AreEqual(id, result.id); }
public int Insert(appointment_test_clinician entity) { if (entity == null) { return(-1); } using (var context = this._context) { context.appointment_test_clinician.Add(entity); var result = context.SaveChanges(); return(result); } }
public int Update(appointment_test_clinician entity) { if (entity == null) { return(-1); } using (var context = this._context) { context.MarkAsModified(entity); var result = context.SaveChanges(); return(entity.id); } }
public void ConvertModelToEntity_Test() { // Arrange TestKolgraphEntities context = new TestKolgraphEntities(); var service = new AppointmentTestEmployeeService(); AppointmentTestEmployeeModel model = GetTestModel(); // Act appointment_test_clinician entity = service.ConvertModelToEntity(model); // Assert Assert.IsNotNull(entity); Assert.AreEqual(model.Id, entity.id); Assert.AreEqual(model.AppointmentTestId, entity.appointmentTestId); Assert.AreEqual(model.Employee.Id, entity.clinicianId); }
public void ConvertEntityToModel_Test() { // Arrange TestKolgraphEntities context = new TestKolgraphEntities(); //var repository = new AppointmentTestEmployeeRepository(context); var service = new AppointmentTestEmployeeService(); appointment_test_clinician entity = context.appointment_test_clinician.Where(x => x.id == 1).FirstOrDefault(); // Act AppointmentTestEmployeeModel model = service.ConvertEntityToModel(entity); // Assert Assert.IsNotNull(model); Assert.AreEqual(model.Id, entity.id); Assert.AreEqual(model.AppointmentTestId, entity.appointmentTestId); Assert.AreEqual(model.Employee.Id, entity.clinicianId); }
public AppointmentTestEmployeeModel ConvertEntityToModel(appointment_test_clinician entity) { if (entity == null) { return(null); } var model = new AppointmentTestEmployeeModel() { Id = entity.id, AppointmentTestId = entity.appointmentTestId, Employee = new EmployeeModelConcise { Id = entity.clinicianId, Name = entity.employee.firstName.Trim() + " " + entity.employee.lastName.Trim() } }; return(model); }
public int Update(AppointmentTestEmployeeModel model, int userId) { appointment_test_clinician entity = this.ConvertModelToEntity(model, userId); return(this._repository.Update(entity)); }
public void MarkAsModified(appointment_test_clinician item) { }