public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "GetStopwatch")] HttpRequestMessage req, TraceWriter log) { var configuration = new HttpConfiguration(); req.Properties[System.Web.Http.Hosting.HttpPropertyKeys.HttpConfigurationKey] = configuration; var data = await req.Content.ReadAsStringAsync(); var requestBody = JsonConvert.DeserializeObject <UserDetailsEntity>(data); if (string.IsNullOrEmpty(requestBody.UserName) && string.IsNullOrEmpty(requestBody.StopWatchName)) { return(req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a username and/or stopwatchname on the query string or in the request body")); } IAzureService azureService = new AzureService(); IStopwatchDetails stopwatchDetails = new StopwatchDetails(azureService); var stopwatchStatus = new GetStatus(stopwatchDetails); var userDetails = JsonConvert.SerializeObject(await stopwatchStatus.RetrieveElapsedTime(requestBody)); //If webjob is running change this to .Retrieve return(req.CreateResponse(HttpStatusCode.OK, userDetails)); }
public StopWatchTimerView(StopwatchDetails details) { InitializeComponent(); UserDetails = details; Details = new ElapsedTimeViewModel(details); BindingContext = Details; }
public ElapsedTimeViewModel(StopwatchDetails stopwatchDetails) { Title = $"{stopwatchDetails.UserName} {stopwatchDetails.StopWatchName}"; var time = TimeSpan.TryParse(stopwatchDetails.ElapsedTime, out TimeSpan serverTimeSpan); _timeSpan = serverTimeSpan; _timerString = stopwatchDetails.ElapsedTime; if (stopwatchDetails.Status != StopwatchStatus.Stop.ToString()) { var sw = new Timer(0.001); sw.Elapsed += Elapsed_Time; sw.Start(); } Details = stopwatchDetails; }
public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = "CreateStopwatch")] HttpRequestMessage req, TraceWriter log) { var data = await req.Content.ReadAsStringAsync(); var requestBody = JsonConvert.DeserializeObject <StopwatchEntity>(data); if (string.IsNullOrEmpty(requestBody.UserName) && string.IsNullOrEmpty(requestBody.StopWatchName)) { return(req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a username and/or stopwatchname on the query string or in the request body")); } IAzureService azureService = new AzureService(); IStopwatchDetails stopwatchDetails = new StopwatchDetails(azureService); var stopwatchStatus = new SaveStatus(stopwatchDetails); stopwatchStatus.Save(requestBody); return(req.CreateResponse(HttpStatusCode.OK)); }