public void Post([FromBody] LaboratoryModelAPI laboratoryModelAPI) { var user = new LaboratoryModel() { Curricula = laboratoryModelAPI.Curricula, Description = laboratoryModelAPI.Description, LabDate = laboratoryModelAPI.LabDate, Number = laboratoryModelAPI.Number, Title = laboratoryModelAPI.Title }; laboratoryService.Add(user); }
public LaboratoryModel Map(LaboratoryModelAPI lab) { return(new LaboratoryModel() { Curricula = lab.Curricula, Date = lab.Date, Description = lab.Description, Number = lab.Number, Title = lab.Title }); }
public async void addLaboratory(LaboratoryModelAPI lab) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpRequestMessage Req = new HttpRequestMessage(HttpMethod.Post, Baseurl + "api/Laboratory"); Req.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(lab), Encoding.ASCII, "application/json"); var Res = await client.PostAsync(Req.RequestUri, Req.Content); } }
private void addLaboratoryButton_Click(object sender, EventArgs e) { if (titleTextBox.Text == null) { return; } if (curriculaTextBox.Text == null) { return; } if (numberTextBox.Text == null) { return; } if (descriptionTextBox.Text == null) { return; } int nr = 0; if (Int32.TryParse(numberTextBox.Text, out nr) == false) { return; } LaboratoryModelAPI lab = new LaboratoryModelAPI(); lab.Title = titleTextBox.Text; lab.Curricula = curriculaTextBox.Text; lab.Number = nr; lab.Description = descriptionTextBox.Text; lab.Date = datePicker.Value.Date; lS.addLaboratory(lab); for (int i = 0; i < 100000000; i++) { ; } refreshGridV(); }
// POST: api/Laboratory public void Post([FromBody] LaboratoryModelAPI value) { lServices.Add(lMapper.Map(value)); }