private bool SaveColonyPicking(QbotPostModel postModel) { ValidateColonyPicking(postModel); if (ModelState.IsValid) { var userJob = new UserJob(); var userJobColonyPicking = new UserJobQbotColonyPicking(); AutoMapper.Mapper.Map(postModel, userJob); AutoMapper.Mapper.Map(postModel, userJobColonyPicking); userJob.UserJobQbotColonyPicking = userJobColonyPicking; userJob.User = GetCurrentUser(true); userJob.RechargeAccount = postModel.RechargeAccount; if (postModel.Strain.IsOther()) { var strain = new Strain() { Name = postModel.NewStrain, Bacteria = postModel.Bacteria, Supplied = false }; userJob.UserJobQbotColonyPicking.Strain = strain; } if (postModel.Vector.IsOther()) { var vector = new Vector() { Name = postModel.NewVector, VectorType = postModel.VectorType, Antibiotic1 = postModel.Antibiotic1, Antibiotic2 = postModel.Antibiotic2 }; userJob.UserJobQbotColonyPicking.Vector = vector; } // add plate var stage = _repositoryFactory.StageRepository.GetNullableById(StageIds.QpWebSubmittedPlates); var barcode = new Barcode() { Stage = stage }; var userJobPlate = new UserJobPlate() { Name = userJob.Name }; userJobPlate.AddBarcode(barcode); userJob.AddUserJobPlates(userJobPlate); _repositoryFactory.UserJobRepository.EnsurePersistent(userJob); return(true); } return(false); }
/// <summary> /// Adds the plates necessary for the original submission /// </summary> /// <param name="plateNames"></param> /// <param name="userJob"></param> private void AddPlates(List <string> plateNames, UserJob userJob, JobType jobType) { // figure out the stage Stage stage = null; switch (jobType.Id) { case (int)JobTypeIds.BacterialClone: stage = _repositoryFactory.StageRepository.GetNullableById(StageIds.BcWebSubmittedPlates); break; case (int)JobTypeIds.PCRProduct: stage = _repositoryFactory.StageRepository.GetNullableById(StageIds.PcrWebSubmittedPlates); break; case (int)JobTypeIds.UserRunSequencing: stage = _repositoryFactory.StageRepository.GetNullableById(StageIds.UrsWebSubmittedPlates); break; case (int)JobTypeIds.PurifiedDna: stage = _repositoryFactory.StageRepository.GetNullableById(StageIds.PdWebSubmittedPlates); break; case (int)JobTypeIds.Sublibrary: stage = _repositoryFactory.StageRepository.GetNullableById(StageIds.SlWebSubmittedPlates); break; } if (stage == null) { throw new ArgumentException("JobType"); } foreach (var name in plateNames) { var plate = new UserJobPlate() { Name = name }; var barcode = new Barcode() { Stage = stage }; plate.AddBarcode(barcode); userJob.AddUserJobPlates(plate); } }
public ActionResult Create(int?id, GenotypingPostModel postModel) { JobType jobType = null; // 2012-10-03 by kjt: Added missing logic to create barcodes using sequencing controller as example. // Added 2013-10-03 by kjt Stage stage = null; if (id.HasValue) { jobType = _repositoryFactory.JobTypeRepository.GetNullableById(id.Value); // check the job type if (!jobType.Genotyping) { Message = "Invalid job type specified"; return(RedirectToAction("Create")); } // Added 2013-10-03 by kjt stage = _repositoryFactory.StageRepository.GetNullableById(StageIds.UgWebSubmittedPlates); postModel.JobType = jobType; } ValidateGenotyping(postModel); if (ModelState.IsValid) { var userJob = new UserJob(); AutoMapper.Mapper.Map(postModel, userJob); userJob.UserJobGenotyping = new UserJobGenotyping(); userJob.User = GetCurrentUser(true); userJob.RechargeAccount = postModel.RechargeAccount; foreach (var did in postModel.Dyes) { userJob.UserJobGenotyping.Dyes.Add(_repositoryFactory.DyeRepository.GetById(did)); } foreach (var name in postModel.PlateNames) { var plate = new UserJobPlate() { Name = name }; // Added 2013-10-03 by kjt var barcode = new Barcode() { Stage = stage }; // Added 2013-10-03 by kjt plate.AddBarcode(barcode); userJob.AddUserJobPlates(plate); } _repositoryFactory.UserJobRepository.EnsurePersistent(userJob); Message = "Your job request has been successfully submitted."; return(RedirectToAction("Index", "Authorized")); } var user = GetCurrentUser(); var viewModel = GenotypingViewModel.Create(_repositoryFactory, user, jobType, postModel); return(View(viewModel)); }
/// <summary> /// Adds the plates necessary for the original submission /// </summary> /// <param name="plateNames"></param> /// <param name="userJob"></param> private void AddPlates(List<string> plateNames, UserJob userJob, JobType jobType) { // figure out the stage Stage stage = null; switch(jobType.Id) { case (int)JobTypeIds.BacterialClone: stage = _repositoryFactory.StageRepository.GetNullableById(StageIds.BcWebSubmittedPlates); break; case (int)JobTypeIds.PCRProduct: stage = _repositoryFactory.StageRepository.GetNullableById(StageIds.PcrWebSubmittedPlates); break; case (int)JobTypeIds.UserRunSequencing: stage = _repositoryFactory.StageRepository.GetNullableById(StageIds.UrsWebSubmittedPlates); break; case (int)JobTypeIds.PurifiedDna: stage = _repositoryFactory.StageRepository.GetNullableById(StageIds.PdWebSubmittedPlates); break; case (int)JobTypeIds.Sublibrary: stage = _repositoryFactory.StageRepository.GetNullableById(StageIds.SlWebSubmittedPlates); break; } if (stage == null) { throw new ArgumentException("JobType"); } foreach(var name in plateNames) { var plate = new UserJobPlate() {Name = name}; var barcode = new Barcode() {Stage = stage}; plate.AddBarcode(barcode); userJob.AddUserJobPlates(plate); } }