public HttpResponseMessage SubmitEvaluation([FromBody] GeneralEvaluation eval) { try { GeneralEvaluationsEntity evalEntity = new GeneralEvaluationsEntity(eval.deviceID, eval.questionNumber); evalEntity.rating = eval.rating; evalEntity.questionNumber = eval.questionNumber; evalEntity.comment = eval.comment; evalEntity.willAttendAgain = eval.WillAttendAgain; evalEntity.timestamp = DateTime.Now; client.InsertUserEval(evalEntity); } catch (AlreadyExistsException e) { return(new HttpResponseMessage(HttpStatusCode.Conflict)); } return(new HttpResponseMessage(HttpStatusCode.OK)); }
public void InsertUserEval(GeneralEvaluationsEntity evalEntity) { // Create a retrieve operation that takes a customer entity. TableOperation retrieveOperation = TableOperation.Retrieve <DevicesEntity>("GeneralEval", evalEntity.deviceID.ToString() + evalEntity.questionNumber); // Execute the retrieve operation. TableResult retrievedResult = table.Execute(retrieveOperation); if (retrievedResult.Result != null) { throw new AlreadyExistsException("Du har allerede afgivet evaluering af denne præsentation"); } // Create the InsertOrReplace TableOperation. TableOperation insertOperation = TableOperation.Insert(evalEntity); // Execute the operation. table.Execute(insertOperation); Console.WriteLine("Entity was updated."); }