public IHttpActionResult Create(JobExecution body) { var jobBody = new JobCreate { Description = body.Description, CallbackUrl = "http://localhost:31901/destination", HttpVerb = "POST", Payload = $"{{ \"description\": \"{body.Description}\" }}", ContentType = "application/json", Headers = "source=Jobbie.Sample.Client.WebApi.Host" }; var scheduleBody = new ScheduleCreate { Description = body.Description, StartUtc = DateTime.UtcNow.AddSeconds(10), Cron = body.Cron }; var schedule = _client .Root() .Post(Relationships.Job_Create, jobBody, Curies.Jobbie) .Post(Relationships.Schedule_Create, scheduleBody, Curies.Jobbie) .Item <Schedule>() .Data; return(Ok(schedule)); }
public async Task Post([FromBody] ScheduleCreate schedule) { // init month schedule var days = this.ExtractDaysScheduleArray(schedule.WorkingDays); var monthSchedule = new MonthScheduleBase { Days = days }; // save the schedule into db await _firebaseDataService.SendIntoFireDatabase(monthSchedule); }
public HttpResponseMessage Create(ScheduleCreate schedule) { if (schedule == null) { ModelState.AddModelError("", "no data"); } if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } letsGoService.Create(schedule); return(Request.CreateResponse(HttpStatusCode.OK)); }
public int Create(ScheduleCreate data) { var scraper = new Scraper(); var pageToScrape = data.EventName.Replace(' ', '_'); var webClient = new WebClient(); var html = webClient.DownloadString("https://en.wikipedia.org/wiki/" + pageToScrape); var parser = new HtmlParser(); var document = parser.Parse(html); var contain = document.QuerySelectorAll(".mw-parser-output > p")[1]; var desc = contain.TextContent; // var desc = document.QuerySelectorAll(".mw-parser-output")[0]; // var hello = desc.QuerySelector("p:nth-child(2)"); // QuerySelectorAll("p")[1].QuerySelector("innerText"); // document.querySelectorAll('.mw-parser-output')[0].querySelectorAll('p')[1].innerText string jsonSchedule = JsonConvert.SerializeObject(data.Schedule); using (var con = GetConnection()) { var cmd = con.CreateCommand(); cmd.CommandText = "Event_Insert"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@json", jsonSchedule); cmd.Parameters.AddWithValue("@EventName", data.EventName); cmd.Parameters.AddWithValue("@State", data.State); cmd.Parameters.AddWithValue("@Description", desc); cmd.Parameters.AddWithValue("@ImageUrl", data.ImageUrl); cmd.Parameters.Add("@id", SqlDbType.Int).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); return((int)cmd.Parameters["@Id"].Value); } }
public IHttpActionResult Create([FromUri] Guid jobId, [FromBody] ScheduleCreate body) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var scheduleId = Guid.NewGuid(); if (body.EndUtc.HasValue) { _scheduler.Create(scheduleId, jobId, body.Description, body.StartUtc, body.Cron, body.EndUtc.Value); } else if (!string.IsNullOrEmpty(body.Cron)) { _scheduler.Create(scheduleId, jobId, body.Description, body.StartUtc, body.Cron); } else { _scheduler.Create(scheduleId, jobId, body.Description, body.StartUtc); } return(Get(scheduleId)); }