public async Task <APIGatewayProxyResponse> GetVerificationAsync(APIGatewayProxyRequest request, ILambdaContext context) { string username = null; if (request.PathParameters.ContainsKey("username")) { username = request.PathParameters["username"].ToString(); } if (!string.IsNullOrEmpty(username)) { var repo = new VerificationRepository(_tableName); var setting = await repo.RetrieveVerificationStatus(username); if (setting != null) { return(new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.OK, Body = JsonConvert.SerializeObject(setting), Headers = _responseHeader }); } } return(new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.NotFound }); }
public static void SendRapport(int inCons, int inDest, DateTime inStart) { var xmlList = Serializer.Load(); for (int i = 0; i < xmlList.Count; i++) { if (xmlList[i].myTrip.User == inCons && xmlList[i].myTrip.Destination == inDest && xmlList[i].myTrip.Start == inStart) { FullTrip full = xmlList[i]; Trip trip = ModelTransformer.TripModel2Trip(full.myTrip); TripRepository.AddTrip(trip); foreach (var vac in full.myVacation) { vac.tripID = trip.tripID; VacationsRepository.AddVacation(ModelTransformer.VacationModel2Vacation(vac)); } foreach (var item in full.myVerifications) { item.tripID = trip.tripID; VerificationRepository.AddVerification(ModelTransformer.VerificationModel2Verification(item)); } xmlList.RemoveAt(i); } } Serializer.Overwrite(xmlList); }
private void btnShowOwnReports_Click(object sender, RoutedEventArgs e) { if (lvReports.SelectedItem != null) { var row = lvReports.SelectedItem.ToString(); string[] col = row.Split(','); string id = Regex.Match(col[0], @"\d+").Value; string[] nameSplit = col[1].Split('='); string name = nameSplit[1].Trim(); string[] destinationSplit = col[2].Split('='); string destination = destinationSplit[1].Trim(); string[] dateSplit = col[3].Split('='); string date = dateSplit[1].Trim(); string[] stateSplit = col[4].Split('='); string state = stateSplit[1].Trim().Substring(0, stateSplit[1].Length - 2); var verifications = VerificationRepository.GetVerifications(Convert.ToInt32(id)); PdfDocument pdf = new PdfDocument(); pdf.Info.Title = name; PdfPage pdfPage = pdf.AddPage(); XGraphics graph = XGraphics.FromPdfPage(pdfPage); XFont font = new XFont("Verdana", 20, XFontStyle.Bold); XFont minifont = new XFont("Verdana", 15); var y = -160; /*XImage img = * XImage.FromFile( * "C:\\Users\\Peter\\Documents\\GitHub\\ResehanteringsSystem\\vITs\\vITs\\Graphics\\pdfImage.gif");*/ //graph.DrawImage(img, 10, 10, 80, 80); graph.DrawString("Anställd: " + name, font, XBrushes.Black, new XRect(0, -330, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); graph.DrawString("Id: " + id, minifont, XBrushes.Black, new XRect(0, -285, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); graph.DrawString("Destination: " + destination, minifont, XBrushes.Black, new XRect(0, -265, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); graph.DrawString("Datum: " + date, minifont, XBrushes.Black, new XRect(0, -245, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); graph.DrawString("Status :" + state, minifont, XBrushes.Black, new XRect(0, -225, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); graph.DrawString("Utgifter", font, XBrushes.Black, new XRect(0, -180, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); foreach (var v in verifications) { graph.DrawString(ExpencesRepository.GetExpence(v.expenceID) + ", Kostnad: " + v.cost + ", Note: " + v.note, minifont, XBrushes.Black, new XRect(0, y, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormat.Center); y -= 20; } string pdfFilename = id + ".pdf"; if (pdfFilename != "") { pdf.Save(pdfFilename); } Process.Start(pdfFilename); } }
public void LoadEmployeeByVerificationKey() { VerificationRepository repo = new VerificationRepository(); VerificationEmployee employee = repo.LoadByKey("0007VT1"); Assert.AreEqual("0007", employee.EmployeeId); Assert.AreEqual("Muhammad Nur Ali Aris", employee.Name); Assert.AreEqual("Jl. Sedanau No. 08 RT01 RW10, Bengkong Kartini, Batam", employee.Address); Assert.AreEqual("Meral Karimun", employee.BirthPlace); Assert.AreEqual(new DateTime(1958,3,1), employee.BirthDate); }
public async Task <APIGatewayProxyResponse> PostMobileVerificationAsync(APIGatewayProxyRequest request, ILambdaContext context) { string username = null; try { if (request.PathParameters.ContainsKey("username")) { username = request.PathParameters["username"].ToString(); } if (!string.IsNullOrEmpty(username)) { var repo = new VerificationRepository(_tableName); var process = JsonConvert.DeserializeObject <VerificationProcess>(request.Body); bool saved = await repo.UpdateMobileVerification(username, process); if (saved) { return(new APIGatewayProxyResponse() { StatusCode = (int)HttpStatusCode.OK, Body = JsonConvert.SerializeObject(process), Headers = _responseHeader }); } } } catch (Exception ex) { context.Logger.LogLine(ex.Message); return(new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.InternalServerError, Body = ex.Message }); } return(new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.BadRequest }); }
public VerificationEmployee GetEmployeeByVerificationKey(string key) { VerificationRepository repo = new VerificationRepository(); return repo.LoadByKey(key); }