public async Task <IActionResult> PostMachine([FromBody] MachineViewModel machine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _machineService.Add(machine);
            _uof.Commit();

            return(Ok(machine));
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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 ! ");
            }
        }
Exemplo n.º 4
0
 public async Task <int> Add(Machine value)
 {
     return(await _service.Add(value));
 }
Exemplo n.º 5
0
 public IActionResult Post([FromBody] Machine model)
 {
     return(Ok(_machineService.Add(model)));
 }