public ActionResult Create(int?id, QbotPostModel postModel) { JobType jobType = null; if (id.HasValue) { jobType = _repositoryFactory.JobTypeRepository.GetNullableById(id.Value); // check the job type if (!jobType.Qbot) { Message = "Invalid job type specified"; return(RedirectToAction("Create")); } postModel.JobType = jobType; } var result = false; switch (jobType.Id) { case (int)JobTypeIds.QbotColonyPicking: result = SaveColonyPicking(postModel); break; case (int)JobTypeIds.QbotPlateReplicating: result = SaveReplicating(postModel); break; case (int)JobTypeIds.QbotGridding: result = SaveGridding(postModel); break; } if (result) { Message = "Saved!"; return(RedirectToAction("Index", "Authorized")); } var user = GetCurrentUser(); var viewModel = QbotViewModel.Create(_repositoryFactory, user, jobType, postModel); return(View(viewModel)); }
public ActionResult Create(int?id) { JobType jobType = null; if (id.HasValue) { jobType = _repositoryFactory.JobTypeRepository.GetNullableById(id.Value); // check the job type if (!jobType.Qbot) { Message = "Invalid job type specified"; return(RedirectToAction("Create")); } } var user = GetCurrentUser(); var viewModel = QbotViewModel.Create(_repositoryFactory, user, jobType); return(View(viewModel)); }