Пример #1
0
        public virtual OperationResult Update(IJob client)
        {
            try
            {
                using var transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions, TransactionScopeAsyncFlowOption.Enabled);
                _dao.Update(client);
                transactionScope.Complete();

                return(new OperationResult <List <IJob> >()
                {
                    Success = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResult <List <IJob> >()
                {
                    Success = false, Exception = e
                });
            }
        }
Пример #2
0
        public ActionResult Edit(EditViewModel model)
        {
            if (ModelState.IsValid)
            {
                Job job = new Job
                {
                    jobID = model.jobID,
                    name  = model.name
                };

                //prevents user from editing a job to a job already exists in the system
                var existingJob = jobDAO.FetchByName(model.name);
                if (existingJob != null)
                {
                    TempData["errorMessage"] = "That Job already exists in the system";
                }

                //edits the job if the job doesn't already exist
                else if (existingJob == null)
                {
                    jobDAO.Update(job);
                    alertService.JobUpdatedAlert(job);

                    if (job != null)
                    {
                        TempData["SuccessMessage"] = "Job was successfully edited";
                    }

                    else
                    {
                        TempData["errorMessage"] = "Error editing job";
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }