Esempio n. 1
0
        public async Task <ActionResult> UpdateTaskInstanceStatus()
        {
            List <Int64> Pkeys   = JsonConvert.DeserializeObject <List <Int64> >(Request.Form["Pkeys"]);
            string       Status  = Request.Form["Status"];
            var          entitys = await _context.TaskInstance.Where(ti => Pkeys.Contains(ti.TaskInstanceId)).ToListAsync();

            foreach (var ti in entitys)
            {
                if (!await CanPerformCurrentActionOnRecord(ti))
                {
                    return(Forbid());
                }
                ti.LastExecutionStatus  = (TaskExecutionStatus)System.Enum.Parse(typeof(TaskExecutionStatus), Status);
                ti.LastExecutionComment = "Manually Updated Status to " + Status + " using WebApp";
                ti.NumberOfRetries      = 0;
                if (Status != "InProgress")
                {
                    ti.TaskRunnerId = null;
                }
            }
            _context.SaveChanges();

            //TODO: Add Error Handling
            return(new OkObjectResult(new { }));
        }