public HttpResponseMessage SubmitEvaluation([FromBody] Evaluation eval) { try { EvaluationsEntity evalEntity = new EvaluationsEntity(eval.deviceID, eval.presentationId); evalEntity.rating = eval.rating; evalEntity.speakerID = eval.speakerId; evalEntity.comment = eval.comment; evalEntity.timestamp = DateTime.Now; client.InsertUserEval(evalEntity); } catch (AlreadyExistsException e) { return(new HttpResponseMessage(HttpStatusCode.Conflict)); } return(new HttpResponseMessage(HttpStatusCode.OK)); }
public void InsertUserEval(EvaluationsEntity evalEntity) { // Create a retrieve operation that takes a customer entity. TableOperation retrieveOperation = TableOperation.Retrieve <DevicesEntity>(partitionKeyConst, evalEntity.deviceID.ToString() + evalEntity.presentationID); // 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."); }