public ActionResult Index(Trip tripId, int headerId, int offset) { // offset should be 0, 20, 40, 60, 80, or 100 // anything else and we should puke here var repo = TubsDataService.GetRepository<LengthSamplingHeader>(MvcApplication.CurrentSession); var header = repo.FindById(headerId); // TODO: What happens when header is not found? // Second check -- make sure this header is in this trip var vm = new SampleColumnViewModel(); vm.Id = header.Id; vm.Offset = offset; int maxSequence = offset + 20; var samples = header.Samples.Where(s => null != s && s.SequenceNumber > offset && s.SequenceNumber <= maxSequence).Take(20); foreach (var sample in samples.OrderBy(s => s.SequenceNumber)) { // First subtraction to get us into the right place within the column // Second subtraction moves us from a one based offset to a zero based offset var position = (sample.SequenceNumber.Value - offset) - 1; if (position < 0 || position > 19) { Logger.ErrorFormat("Sample with Id {0} has a strange offset", sample.Id); continue; } vm.Samples[position] = new PurseSeineSampleViewModel() { Id = sample.Id, Number = sample.SequenceNumber.Value, SpeciesCode = sample.SpeciesCode, Length = sample.Length }; } return View(vm); }
public JsonResult Edit(Trip tripId, int headerId, SampleColumnViewModel scvm) { throw new NotImplementedException(); }