public async Task <IActionResult> PostMachine([FromBody] MachineViewModel machine) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _machineService.Add(machine); _uof.Commit(); return(Ok(machine)); }
public void SetMachine(string jsonObject) { var machineViewModel = JsonConvert.DeserializeObject <MachineViewModel>(jsonObject); if (_machineService.GetByMacAdress(machineViewModel.MacAddress) != null) { _machineService.Update(machineViewModel); } else { _machineService.Add(machineViewModel); } _uof.Commit(); }
private void btnAdd_Click(object sender, EventArgs e) { bool isEmpty = (string.IsNullOrWhiteSpace(tbIp.Text) || string.IsNullOrWhiteSpace(tbMachineName.Text) || string.IsNullOrWhiteSpace(tbCategory.Text)); if (!isEmpty) { Machine machine = new Machine { Ip = tbIp.Text.ToString(), MachineName = tbMachineName.Text.ToString(), CategoryId = Int16.Parse(tbCategory.Text.ToString()) }; _machineService.Add(machine); MessageBox.Show("Kayıt Eklendi"); tbIp.Text = ""; tbMachineName.Text = ""; tbCategory.Text = ""; dgvMachines.DataSource = _machineService.GetAll(); } else { MessageBox.Show("Eksik yerleri doldurunuz ! "); } }
public async Task <int> Add(Machine value) { return(await _service.Add(value)); }
public IActionResult Post([FromBody] Machine model) { return(Ok(_machineService.Add(model))); }