public async Task <ActionResult> ConfermaProv([FromBody] JObject data)
        {
            var part   = data["PartID"].ToObject <string>();
            var serial = data["SerialID"].ToObject <string>();

            if (checkPartSerial(part, serial))
            {
                Strumento str = new Strumento();
                str.PartId      = part;
                str.SerialId    = serial;
                str.Nome        = data["Nome"].ToObject <string>();
                str.Marca       = data["Marca"].ToObject <string>();
                str.Modello     = data["Modello"].ToObject <string>();
                str.Descrizione = data["Descrizione"].ToObject <string>();
                str.Posizione   = data["Posizione"].ToObject <string>();;
                str.Status      = data["Status"].ToObject <int>();
                str.TTL         = data["TTL"].ToObject <DateTime>();
                _context.Strumento.Add(str);
                await _context.SaveChangesAsync();

                StrumentoProvvisorio strProv = _context.StrumentoProvvisorio.Find(data["Id"].ToObject <string>());
                _context.StrumentoProvvisorio.Remove(strProv);
                await _context.SaveChangesAsync();

                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
        public StrumentoVisualizzation(int idStrumento)
        {
            InitializeComponent();
            this.Icon = Properties.Resources.iconmain;
            Strumento strumento = (from s in RicettarioDB.getInstance().Strumento
                                   where s.idStrumento == idStrumento
                                   select s).First();

            this.nome.Text = strumento.Nome;
            if (strumento.TipoElettrodom != null)
            {
                this.Elettrodomestico.Text = "Tipo = " + strumento.TipoElettrodom;
                this.potenza.Text          = " potenza = " + strumento.Potenza + " Watt";
            }
            else
            {
                this.Elettrodomestico.Text = "";
                this.potenza.Text          = "";
            }
            this.StartPosition        = FormStartPosition.CenterParent;
            this.descrizione.ReadOnly = true;
            this.descrizione.Text     = strumento.Descrizione;

            this.immagine.Image = (Image)Properties.Resources.ResourceManager.GetObject(strumento.Immagine);
        }
        public async Task <ActionResult> PostStrumento([FromBody] JObject data)
        {
            var desc      = data["Descrizione"].ToObject <string>();
            var strumento = data["Strumento"].ToObject <Strumento>();

            strumento.Status      = 1;
            strumento.Descrizione = desc;
            var s = new Strumento();

            s.PartId      = strumento.PartId;
            s.SerialId    = strumento.SerialId;
            s.Descrizione = strumento.Descrizione;
            s.Status      = strumento.Status;
            s.Nome        = strumento.Nome;
            s.Marca       = strumento.Marca;
            s.Modello     = strumento.Modello;
            s.Posizione   = strumento.Posizione;
            s.TTL         = strumento.TTL;
            s.Delicato    = strumento.Delicato;
            if (strumento.PDFPath != null)
            {
                s.PDFPath = strumento.PDFPath;
            }
            if (strumento.ImgPath != null)
            {
                s.ImgPath = strumento.ImgPath;
            }
            s.numManutenzioni = 0;


            _context.Strumento.Add(strumento);
            await _context.SaveChangesAsync();

            return(Ok());
        }