//public JobBO() //{ // _dao = new ClientDAO(); //} /* * CRUD + LIST */ #region CREATE public virtual OperationResult Create(IJob client) { try { using var transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions, TransactionScopeAsyncFlowOption.Enabled); _dao.Create(client); transactionScope.Complete(); return(new OperationResult <List <IJob> >() { Success = true }); } catch (Exception e) { return(new OperationResult <List <IJob> >() { Success = false, Exception = e }); } }
public ActionResult Create(CreateViewModel model) { if (ModelState.IsValid) { Job job = new Job { name = model.name }; //prevents user from creating a job that already exists in the system var existingJob = jobDAO.FetchByName(model.name); if (existingJob != null) { TempData["errorMessage"] = "That Job already exists in the system"; } //adds the job if it doesn't already exist else if (existingJob == null) { jobDAO.Create(job); alertService.JobCreatedAlert(job); if (job != null) { TempData["SuccessMessage"] = "Job was successfully created"; } else { TempData["errorMessage"] = "Error saving job"; } } return(RedirectToAction("Index")); } return(View(model)); }