Exemple #1
0
        public AppointmentTestEmployeeModel GetById(int id)
        {
            appointment_test_clinician   entity = this._repository.GetById(id);
            AppointmentTestEmployeeModel model  = this.ConvertEntityToModel(entity);

            return(model);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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);
            }
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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);
            }
        }
Exemple #7
0
        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);
            }
        }
Exemple #8
0
        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);
        }
Exemple #9
0
        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);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        public int Update(AppointmentTestEmployeeModel model, int userId)
        {
            appointment_test_clinician entity = this.ConvertModelToEntity(model, userId);

            return(this._repository.Update(entity));
        }
Exemple #12
0
 public void MarkAsModified(appointment_test_clinician item)
 {
 }