public async Task <IHttpActionResult> SubmitTask(AddRequest param)
        {
            try
            {
                using (var context = new LeaveRequestDataContext())
                {
                    var usr   = context.Employees.Where(o => o.ID == param.ID).SingleOrDefault();
                    var token = usr.Token;

                    var bodyCreate = "{" +
                                     "\"data\": {" +
                                     "\"form_data\": {" +
                                     "\"pvAction\" : \"" + param.Action + "\"" +
                                     "}," +
                                     "\"comment\": \"ThisComent\"" +
                                     "}" +
                                     "}";

                    JObject jsonCreate = JObject.Parse(bodyCreate);
                    var     action     = string.Empty;

                    using (var client = new HttpClient())
                    {
                        client.BaseAddress = new Uri("https://mosaic.dev.nextflow.tech/");
                        client.DefaultRequestHeaders.Accept.Clear();
                        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
                        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                        var response = await client.PostAsJsonAsync("nextflow/api/tasks/" + param.TaskId + "/submit", jsonCreate);

                        var result = await response.Content.ReadAsAsync <dynamic>();
                    }
                    if (param.Action == "Approve" || param.Action == "Disapprove")
                    {
                        var leaveReq = context.ListLeaveRequests.Where(o => o.ProcessId == param.ProcessId).SingleOrDefault();
                        leaveReq.status = param.Action;
                        context.SubmitChanges();

                        if (param.Action == "Approve")
                        {
                            var employ = context.Employees.Where(o => o.Email == leaveReq.Email).SingleOrDefault();
                            employ.Balance = (int)employ.Balance + (int)param.DaysLeave;
                            context.SubmitChanges();
                        }
                    }

                    commentHistory commentHistory = new commentHistory();

                    commentHistory.ProcessId = param.ProcessId;
                    commentHistory.Name      = usr.Name;
                    commentHistory.Action    = param.Action;
                    commentHistory.Date      = DateTime.Now;
                    commentHistory.Comment   = "jajajaj";

                    context.commentHistories.InsertOnSubmit(commentHistory);
                    context.SubmitChanges();


                    return(Ok(new { success = true, message = "Leave Request " + action }));
                }
            }
            catch (Exception ex)
            {
                return(Ok(new { success = false, message = ex.Message }));
            }
        }
        public async Task <IHttpActionResult> Create([FromBody] AddRequest req)
        {
            var              flowId  = ConfigurationManager.AppSettings["FlowId"];
            commentHistory   comment = new commentHistory();
            ListLeaveRequest leave   = new ListLeaveRequest();

            using (var dc = new LeaveRequestDataContext())
            {
                var    user      = dc.Employees.Where(o => o.Email == req.Email).SingleOrDefault();
                string recordId  = string.Empty;
                string processId = string.Empty;

                var bodyCreate = "{ " +
                                 "\"data\": { " +
                                 " \"definition\": { " +
                                 " \"id\": \"" + flowId + "\"" +
                                 "}" +
                                 "}" +
                                 "}";

                JObject jsonCreate = JObject.Parse(bodyCreate);

                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("https://mosaic.dev.nextflow.tech/");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", user.Token);
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    var response = await client.PostAsJsonAsync("nextflow/api/records", jsonCreate);

                    var result = await response.Content.ReadAsAsync <dynamic>();

                    recordId = result.data.id;

                    var bodySubmit = "{ " +
                                     "\"data\": { " +
                                     " \"form_data\": { " +
                                     " \"pvInitiator\": \"" + user.Email + "\"," +
                                     " \"pvInitiatorName\": \"" + user.Name + "\"," +
                                     " \"pvAction\": \"Submit\"," +
                                     " \"pvReq\": \"" + user.Email + "\"," +
                                     " \"pvApprover\":\"[email protected]\"" +
                                     "}," +
                                     "\"comment\" : \"" + req.comment + "\"" +
                                     "}" +
                                     "}";

                    JObject jsonSubmit     = JObject.Parse(bodySubmit);
                    var     responseSubmit = await client.PostAsJsonAsync("nextflow/api/records/" + recordId + "/submit", jsonSubmit);

                    var resultSubmit = await responseSubmit.Content.ReadAsAsync <dynamic>();

                    processId = resultSubmit.data.process_id;
                }

                leave.Name       = req.Name;
                leave.Email      = req.Email;
                leave.DaysLeave  = req.DaysLeave;
                leave.ProcessId  = processId;
                leave.RecordId   = recordId;
                leave.StartDate  = req.StartDate;
                leave.EndDate    = req.EndDate;
                leave.DaysLeave  = req.DaysLeave;
                leave.Submission = DateTime.Now;
                leave.status     = req.status;
                leave.LeaveType  = req.LeaveType;


                dc.ListLeaveRequests.InsertOnSubmit(leave);


                comment.Name      = req.Name;
                comment.ProcessId = req.ProcessId;
                comment.Action    = "Submit";
                comment.Comment   = req.comment;
                dc.commentHistories.InsertOnSubmit(comment);

                dc.SubmitChanges();
            }
            return(Ok("Sukses"));
        }