public IHttpActionResult DeleteUtilizatori(int userID) { _context = new PracticaSerraUpdateEntities(); try { _context.DeleteUtilizatori(userID); return(Ok("deleted")); } catch (Exception ex) { return(InternalServerError()); } }
private PracticaSerraUpdateEntities _context; //obiect ce tine loc de conexiune la baza de date public IHttpActionResult GetUtilizatotiInfo() { _context = new PracticaSerraUpdateEntities(); try { var users = _context.GetAllUsers().ToList(); return(Ok(users)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public IHttpActionResult GetPlantationInfo() { _context = new PracticaSerraUpdateEntities(); try { dynamic plantations = _context.GetAllPlantations(); return(Ok(plantations)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public IHttpActionResult UpdateUsers([FromBody] dynamic userInfo) { _context = new PracticaSerraUpdateEntities(); try { int ID = userInfo["ID"]; String nume = userInfo["Nume"]; String prenume = userInfo["Prenume"]; String email = userInfo["email"]; decimal telephone = userInfo["telephone"]; _context.UpdateUtilizator(ID, nume, prenume, email, telephone); return(Ok("Updated")); } catch (Exception ex) { return(InternalServerError()); } }
public IHttpActionResult AddUtilizatori([FromBody] dynamic Utilizator) { _context = new PracticaSerraUpdateEntities(); try { String username = Utilizator["Username"]; String password = Utilizator["Password"]; String nume = Utilizator["Nume"]; String prenume = Utilizator["Prenume"]; String email = Utilizator["email"]; decimal telephone = Utilizator["telephone"]; _context.AddUtilizator(username, password, nume, prenume, email, telephone, 0); return(Ok("Adaugat")); } catch (Exception ex) { return(InternalServerError()); } }
public IHttpActionResult GetWorkersStats() { _context = new PracticaSerraUpdateEntities(); Hashtable Stats_hashtable = new Hashtable(); try { var max = _context.BiggestQuantity(); var nmax = _context.NumberOfProductiveWorkers(); var tq = _context.TotalQuantity(); var aq = _context.AverageQuantity(); Stats_hashtable.Add("Biggest Quantity", max); Stats_hashtable.Add("Workers that got a big Quantity", nmax); Stats_hashtable.Add("Total Quantity picked Up today:", tq); Stats_hashtable.Add("Average Quantity per Worker", aq); return(Ok(Stats_hashtable)); } catch (Exception ex) { return(InternalServerError()); } }