public appointment_employee ConvertModelToEntity(AppointmentEmployeeModel model, int userId = -1) { appointment_employee entity = new appointment_employee(); if (model == null) { return(null); } entity.appointmentId = model.AppointmentId; entity.employeeId = model.Employee.Id; 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 AppointmentEmployeeModel GetById(int id) { appointment_employee entity = this._repository.GetById(id); AppointmentEmployeeModel model = this.ConvertEntityToModel(entity); return(model); }
public int Insert(int appointmentId, int employeeId, int userId) { AppointmentEmployeeModel model = new AppointmentEmployeeModel { Id = -1, AppointmentId = appointmentId, Employee = new EmployeeModelConcise { Id = employeeId } }; appointment_employee entity = this.ConvertModelToEntity(model, userId); return(this._repository.Insert(entity)); }
public appointment_employee GetById(Int64 id) { using (var context = this._context) { appointment_employee entity = context.appointment_employee.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 AppointmentEmployeeRepository(context); int id = 1; // Act appointment_employee result = repository.GetById(id); // Assert Assert.IsNotNull(result); Assert.AreEqual(id, result.id); }
public int Insert(appointment_employee entity) { if (entity == null) { return(-1); } using (var context = this._context) { context.appointment_employee.Add(entity); var result = context.SaveChanges(); return(result); } }
public int Update(appointment_employee 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 AppointmentEmployeeService(); AppointmentEmployeeModel model = GetTestModel(); // Act appointment_employee entity = service.ConvertModelToEntity(model); // Assert Assert.IsNotNull(entity); Assert.AreEqual(model.Id, entity.id); Assert.AreEqual(model.AppointmentId, entity.appointmentId); Assert.AreEqual(model.Employee.Id, entity.employeeId); }
public void ConvertEntityToModel_Test() { // Arrange TestKolgraphEntities context = new TestKolgraphEntities(); //var repository = new AppointmentEmployeeRepository(context); var service = new AppointmentEmployeeService(); appointment_employee entity = context.appointment_employee.Where(x => x.id == 1).FirstOrDefault(); // Act AppointmentEmployeeModel model = service.ConvertEntityToModel(entity); // Assert Assert.IsNotNull(model); Assert.AreEqual(model.Id, entity.id); Assert.AreEqual(model.AppointmentId, entity.appointmentId); Assert.AreEqual(model.Employee.Id, entity.employeeId); }
public AppointmentEmployeeModel ConvertEntityToModel(appointment_employee entity) { if (entity == null) { return(null); } var model = new AppointmentEmployeeModel() { Id = entity.id, AppointmentId = entity.appointmentId, Employee = new EmployeeModelConcise { Id = entity.employeeId, Name = entity.employee.firstName.Trim() + " " + entity.employee.lastName.Trim() } }; return(model); }
public int Update(AppointmentEmployeeModel model, int userId) { appointment_employee entity = this.ConvertModelToEntity(model, userId); return(this._repository.Update(entity)); }
public void MarkAsModified(appointment_employee item) { }