public appointment_hitchayvut ConvertModelToEntity(AppointmentHitchayvutModel model, int userId = -1) { appointment_hitchayvut entity = new appointment_hitchayvut(); if (model == null) { return(null); } entity.appointmentId = model.AppointmentId; entity.hitchayvutId = model.Hitchayvut.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 AppointmentHitchayvutModel GetById(int id) { appointment_hitchayvut entity = this._repository.GetById(id); AppointmentHitchayvutModel model = this.ConvertEntityToModel(entity); return(model); }
public int Insert(int appointmentId, int hitchayvutId, int userId) { AppointmentHitchayvutModel model = new AppointmentHitchayvutModel { Id = -1, AppointmentId = appointmentId, Hitchayvut = new HitchayvutModel { Id = hitchayvutId } }; appointment_hitchayvut entity = this.ConvertModelToEntity(model, userId); return(this._repository.Insert(entity)); }
public appointment_hitchayvut GetById(Int64 id) { using (var context = this._context) { appointment_hitchayvut entity = context.appointment_hitchayvut.AsNoTracking() .Include(x => x.hitchayvut) .Where(x => x.id == id) .FirstOrDefault(); return(entity); } }
public int Insert(appointment_hitchayvut entity) { if (entity == null) { return(-1); } using (var context = this._context) { context.appointment_hitchayvut.Add(entity); var result = context.SaveChanges(); return(result); } }
public int Update(appointment_hitchayvut entity) { if (entity == null) { return(-1); } using (var context = this._context) { context.MarkAsModified(entity); var result = context.SaveChanges(); return(entity.id); } }
public void GetById_Test() { // Arrange TestKolgraphEntities context = new TestKolgraphEntities(); var repository = new AppointmentHitchayvutRepository(context); int id = 1; // Act appointment_hitchayvut result = repository.GetById(id); // Assert Assert.IsNotNull(result); Assert.AreEqual(id, result.id); }
public void ConvertModelToEntity_Test() { // Arrange TestKolgraphEntities context = new TestKolgraphEntities(); var service = new AppointmentHitchayvutService(); AppointmentHitchayvutModel model = GetTestModel(); // Act appointment_hitchayvut entity = service.ConvertModelToEntity(model); // Assert Assert.IsNotNull(entity); Assert.AreEqual(model.Id, entity.id); Assert.AreEqual(model.AppointmentId, entity.appointmentId); Assert.AreEqual(model.Hitchayvut.Id, entity.hitchayvutId); }
public AppointmentHitchayvutModel ConvertEntityToModel(appointment_hitchayvut entity) { if (entity == null) { return(null); } var model = new AppointmentHitchayvutModel() { Id = entity.id, AppointmentId = entity.appointmentId, Hitchayvut = entity.hitchayvut == null ? null : _hitchayvutService.ConvertEntityToModel(entity.hitchayvut) }; return(model); }
public void ConvertEntityToModel_Test() { // Arrange TestKolgraphEntities context = new TestKolgraphEntities(); var service = new AppointmentHitchayvutService(); appointment_hitchayvut entity = context.appointment_hitchayvut.Where(x => x.id == 1).FirstOrDefault(); // Act AppointmentHitchayvutModel model = service.ConvertEntityToModel(entity); // Assert Assert.IsNotNull(model); Assert.AreEqual(model.Id, entity.id); Assert.AreEqual(model.AppointmentId, entity.appointmentId); if (entity.hitchayvut == null) { Assert.AreEqual(model.Hitchayvut, null); } else { Assert.AreEqual(model.Hitchayvut.Id, entity.hitchayvutId); } }
public int Update(AppointmentHitchayvutModel model, int userId) { appointment_hitchayvut entity = this.ConvertModelToEntity(model, userId); return(this._repository.Update(entity)); }
public void MarkAsModified(appointment_hitchayvut item) { }