Beispiel #1
0
        public static async Task <IActionResult> UpdateTask([HttpTrigger(AuthorizationLevel.Function, "put", Route = "maintenance/{id}/tasks/{taskID}")] HttpRequest req, string id, string taskID, ILogger log)
        {
            log.LogInformation($"Update existing task in check request");

            try
            {
                string     _RequestBody = await new StreamReader(req.Body).ReadToEndAsync();
                TaskEntity _Entity      = JsonConvert.DeserializeObject <TaskEntity>(_RequestBody);

                if (await TasksRepo.Get(taskID) != null)
                {
                    await TasksRepo.Update(taskID, _Entity);
                }
                else
                {
                    return(new NotFoundResult());
                }
            }
            catch (Exception _Exception)
            {
                log.LogError(_Exception.Message);
                return(new NotFoundResult());
            }

            return(new OkResult());
        }
Beispiel #2
0
        public static async Task <IActionResult> AddNewTaskToMaintenanceCheck([HttpTrigger(AuthorizationLevel.Function, "post", Route = "maintenance/{id}/tasks/")] HttpRequest req, string id, ILogger log)
        {
            log.LogInformation($"Add new task to check request");

            try
            {
                string     _RequestBody = await new StreamReader(req.Body).ReadToEndAsync();
                TaskEntity _Entity      = JsonConvert.DeserializeObject <TaskEntity>(_RequestBody);
                await TasksRepo.Create(_Entity);
            }
            catch (Exception _Exception)
            {
                log.LogError("Error in Deserializing");
                log.LogError(_Exception.Message);
                return(new BadRequestResult());
            }

            return(new OkResult());
        }
Beispiel #3
0
        public static async Task <IActionResult> RemoveTask([HttpTrigger(AuthorizationLevel.Function, "delete", Route = "maintenance/{id}/tasks/{taskID}")] HttpRequest req, string id, string taskID, ILogger log)
        {
            log.LogInformation($"Remove task in check request");

            try
            {
                if (await TasksRepo.Get(taskID) != null)
                {
                    await TasksRepo.Remove(taskID);
                }
                else
                {
                    return(new NotFoundResult());
                }
            }
            catch (Exception _Exception)
            {
                log.LogError(_Exception.Message);
                return(new NotFoundResult());
            }

            return(new OkResult());
        }
Beispiel #4
0
 public TaskSer()
 {
     taskRepo = new TasksRepo();
 }