Пример #1
0
        public ActionResult EditStep(reasons editStep)
        {
            user.ValidateUser();

            try
            {
                taskBusiness.ChangeStep(editStep);

                return(Json(editStep, JsonRequestBehavior.AllowGet)); //cuidado aqui .step.DescriptionStep
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(404, ex.Message));
            }
        }
Пример #2
0
        public reasons SaveReason(reasons reasons)
        {
            try
            {
                checkListDB.reasons.Add(reasons);

                checkListDB.SaveChanges();

                return(reasons);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #3
0
        // Editar aqui Para diferentes tipos de Status
        public reasons ChangeStep(reasons statusStep)
        {
            checkListDB.Configuration.ProxyCreationEnabled = false;

            //Lambda para buscar uma tarefa pelo ID
            var task = checkListDB.tasks.FirstOrDefault(c => c.IdTask == statusStep.IdTask);
            var step = checkListDB.step.FirstOrDefault(id => id.IdStep == statusStep.IdStep);

            task.IdStep = statusStep.IdStep;
            task.step   = step;
            task.LastDescriptionReason = statusStep.Description ?? "-";

            var reason = new reasons()
            {
                IdStep      = step.IdStep,
                IdTask      = task.IdTask,
                Description = statusStep.Description ?? "-",
                ChangeDate  = DateTime.Now,
                step        = step,
                tasks       = task
            };

            try
            {
                SaveReason(reason);

                checkListDB.tasks.Attach(task);
                checkListDB.Entry(task).Property(x => x.IdStep).IsModified = true;
                checkListDB.Entry(task).Property(x => x.LastDescriptionReason).IsModified = true;
                checkListDB.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(reason);
        }