public JsonResult Post(ResocontoLavoro r)
 {
     using (var context = new core.SHIFT_MANAGERContext())
     {
         Thread.Sleep(3000);
         // passo il resoconto alla funzione che estrae, salva le immagini
         // se la funzione va  a buon fine, negli scontrini ho dentro la path
         if (_imgWorker.ScontrinoHandler(r))
         {
             try
             {
                 context.ResocontoLavoro.Add(r);
                 return(new JsonResult(new { RowEffected = context.SaveChanges() }));
             }
             catch (Exception ex) {
                 Trace.WriteLine("Errore nel salvataggio database del resoconto lavori" + ex.Message);
                 return(new JsonResult(new {
                     RowEffected = 0,
                     Error = ex.InnerException.InnerException.Message
                 }));
             }
         }
         else
         {
             return(new JsonResult(new {
                 RowEffected = 0,
                 Error = "Errore nella gestione salvataggio scontrini."
             }));
         }
     }
 }
 public JsonResult Get(int?utenteId, int?commessaId)
 {
     if (commessaId.HasValue && utenteId.HasValue)
     {
         using (var context = new core.SHIFT_MANAGERContext())
         {
             try
             {
                 var t = context.ResocontoLavoro.Where(w => w.UtenteId == utenteId && w.CommessaId == commessaId)
                         .OrderByDescending(i => i.DataIntervento).ThenByDescending(r => r.ResocontoId).ToList();
                 return(new JsonResult(t));
             }
             catch (Exception ex) {
                 throw new NotImplementedException();
                 return(null);
             }
         }
     }
     if (utenteId.HasValue && !commessaId.HasValue)
     {
         using (var context = new core.SHIFT_MANAGERContext())
         {
             try
             {
                 var t = context.ResocontoLavoro.Where(w => w.UtenteId == utenteId).ToList();
                 return(new JsonResult(t));
             }
             catch (Exception ex) {
                 throw new NotImplementedException();
                 return(null);
             }
         }
     }
     if (!utenteId.HasValue && commessaId.HasValue)
     {
         using (var context = new core.SHIFT_MANAGERContext())
         {
             try
             {
                 var t = context.ResocontoLavoro.Where(w => w.CommessaId == commessaId).ToList();
                 return(new JsonResult(t));
             }
             catch (Exception ex) {
                 throw new NotImplementedException();
                 return(null);
             }
         }
     }
     else
     {
         return(new JsonResult(null));
     }
 }
Exemplo n.º 3
0
 public JsonResult Get(int clienteId)
 {
     using (var context = new core.SHIFT_MANAGERContext())
     {
         try
         {
             var t = context.Commesse.Where(w => w.ClienteId == clienteId).Select(c => new { c.Nome, c.CommessaId }).ToList();
             return(new JsonResult(t));
         }
         catch (Exception ex) {
             throw new NotImplementedException();
             return(null);
         }
     }
 }
Exemplo n.º 4
0
 public JsonResult Get(string query)
 {
     using (var context = new core.SHIFT_MANAGERContext())
     {
         try
         {
             var t = context.Clienti.Select(c => new { c.Nome, c.ClienteId }).ToList();
             return(new JsonResult(t));
         }
         catch (Exception ex) {
             throw new NotImplementedException();
             return(null);
         }
     }
 }