public HttpResponseMessage Post(EvaluationTO evaluation)
        {
            evaluation = model.Add(evaluation);
            HttpResponseMessage response = Request.CreateResponse <EvaluationTO>(HttpStatusCode.Created, evaluation);

            response.Headers.Location = new Uri(Request.RequestUri + apiUrl + evaluation.ID.ToString());

            return(response);
        }
        public HttpResponseMessage Put(EvaluationTO evaluation)
        {
            if (!model.Exists(evaluation.ID))
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            model.Update(evaluation);
            HttpResponseMessage response = Request.CreateResponse <EvaluationTO>(HttpStatusCode.OK, evaluation);

            return(response);
        }
        public EvaluationTO Delete(int id)
        {
            EvaluationTO evaluation = model.Get(id);

            if (evaluation == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            model.Delete(evaluation);
            return(evaluation);
        }
示例#4
0
        public static List <EvaluationTO> GetAll()
        {
            List <EvaluationTO> list = new List <EvaluationTO>();

            DataTable table = ExecuteCommand("SELECT ID, Name, Description FROM Evaluation");

            foreach (DataRow item in table.Rows)
            {
                EvaluationTO element = MapElement(item);
                list.Add(element);
            }

            return(list);
        }
        public EvaluationTO Add(EvaluationTO evaluation)
        {
            evaluation = db.Evaluations.Add(evaluation);

            return(evaluation);
        }
 public void Update(EvaluationTO evaluation)
 {
     db.Entry(evaluation).CurrentValues.SetValues(evaluation);
 }
 public void Delete(EvaluationTO evaluation)
 {
     db.Evaluations.Remove(evaluation);
 }