void IJobAdsRepository.ChangeStatus(Guid jobAdId, JobAdStatus newStatus, DateTime?newExpiryTime, DateTime time) { using (var dc = CreateContext()) { // Update the status on the job ad itself. var entity = GetJobAdEntity(dc, jobAdId); var previousStatus = entity.status; entity.status = (byte)newStatus; entity.lastUpdatedTime = time; if (newExpiryTime != null) { entity.expiryTime = newExpiryTime.Value; } // Record the change. var change = new JobAdStatusChange { Id = Guid.NewGuid(), Time = time, PreviousStatus = (JobAdStatus)previousStatus, NewStatus = newStatus }; dc.JobAdStatusEntities.InsertOnSubmit(change.Map(jobAdId)); dc.SubmitChanges(); } }
public static JobAdStatusEntity Map(this JobAdStatusChange change, Guid jobAdId) { var entity = new JobAdStatusEntity { id = change.Id, jobAdId = jobAdId, }; change.MapTo(entity); return(entity); }
void IJobAdsRepository.UpdateStatusChange(JobAdStatusChange change) { using (var dc = CreateContext()) { var entity = GetJobAdStatusEntity(dc, change.Id); if (entity != null) { change.MapTo(entity); dc.SubmitChanges(); } } }
void IJobAdsRepository.UpdateStatusChange(JobAdStatusChange change) { throw new NotImplementedException(); }
public static void MapTo(this JobAdStatusChange change, JobAdStatusEntity entity) { entity.previousStatus = (byte)change.PreviousStatus; entity.newStatus = (byte)change.NewStatus; entity.time = change.Time; }