public async Task <ElStatusResponse> UpdateStatus(Guid userid, DateTime attendanceDate, decimal EL, int Hrstatus) { PayrollRequest reqModel = new PayrollRequest(); ElStatusResponse res = new ElStatusResponse(); if (userid != null && attendanceDate != null) { reqModel.Leave = EL.ToString(); reqModel.Type = Convert.ToString(Hrstatus); reqModel.UserId = userid; var date = attendanceDate; reqModel.AttendanceDate = date.ToString("yyyy-MM-dd"); //decimal a2 = TryParsedecimal("234.53453424233432423432", decimal.MinValue); } var client = new RestClient(Constants.ApiUrl); var request = new RestRequest(Constants.ApiUrl, Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(reqModel); request.AddHeader("email", UserEmail); try { var response = client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { res = JsonConvert.DeserializeObject <ElStatusResponse>(response.Content); } return(res); } catch (Exception error) { res.status = "Not updated successfully"; res.totalel = "0"; return(res); } }
public async Task SendIntimationWithELIntent(IDialogContext context, LuisResult result) { string token; if (context.PrivateConversationData.TryGetValue(AuthTokenKey, out token)) { string userid = string.Empty, attendanceDate = string.Empty, Email = string.Empty, count = string.Empty, time = string.Empty, HRStatus = string.Empty; ElStatusResponse Apiresponse = new ElStatusResponse(); var option = result.Query.Substring(0, 2); var splitdata = result.Query.Split(' '); var entityCount = splitdata.Length; var atte = DateTime.Now; if (entityCount > 0) { userid = splitdata[1]; Email = splitdata[5]; count = splitdata[4]; time = splitdata[3]; attendanceDate = splitdata[2]; HRStatus = splitdata[6]; } if (option == "O1") { decimal el = 0.5m; var user = Guid.Parse(userid); atte = DateTime.Parse(attendanceDate); var status = Int32.Parse(HRStatus); Apiresponse = await UpdateStatus(user, atte, el, status); } else { var user = Guid.Parse(userid); atte = DateTime.Parse(attendanceDate); var status = Int32.Parse(HRStatus); Apiresponse = await UpdateStatus(user, atte, 0, status); } if (HRStatus != "5") { if (Apiresponse.status.Contains("already")) { await context.PostAsync($"{Apiresponse.status}"); } else { string member = "Member"; if (Apiresponse != null) { string[] data = Apiresponse.status.Split(':'); member = data[1].Split(' ')[1]; var status = await sendMail(Email, atte.ToString("dd/MM/yyyy"), time, option, member, Apiresponse.numofel, Apiresponse.totalel); if (status == true) { await context.PostAsync(Apiresponse.status); } //else //{ // await context.PostAsync($"Mail sending is failed"); //} } } } else { await context.PostAsync($"{Apiresponse.status}"); } context.Wait(MessageReceived); } else { await context.PostAsync($"Please Login First!!"); } }