Beispiel #1
0
        public async Task SendNotation(NotationPost notationPost)
        {
            var jsonRequest = JsonConvert.SerializeObject(notationPost);
            var content     = new StringContent(jsonRequest, Encoding.UTF8, "text/json");

            try
            {
                var response = await httpClient.PostAsync("https://smartcity-webapp.azurewebsites.net/api/notations/", content);

                await new MessageDialog("Note créée avec succès", "Création réussie").ShowAsync();
            }
            catch (HttpRequestException)
            {
                await new MessageDialog("Envoi impossible de la note", "Erreur").ShowAsync();
            }
        }
Beispiel #2
0
 public Boolean ValidateNotation()
 {
     if (!String.IsNullOrWhiteSpace(CommentContent))
     {
         NotationToPost = new NotationPost()
         {
             OriginID  = ViewModelLocator.ConnectedUser.ID,
             HousingID = SelectedHousing.ID,
             Comment   = CommentContent,
             Quotation = QuotationValue
         };
         return(true);
     }
     else
     {
         new MessageDialog("Veuillez justifier votre cotation via un commentaire", "Erreur").ShowAsync();
         return(false);
     }
 }
Beispiel #3
0
        public async Task <IHttpActionResult> PostNotation(NotationPost notationPost)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Notation notation = new Notation()
            {
                Comment      = notationPost.Comment,
                Quotation    = notationPost.Quotation,
                DateNotation = DateTime.Now
            };

            //notation.Origin = db.UserDB.First(u => u.ID == notationPost.OriginID);
            notation.Origin  = db.UserDB.First(u => u.ID == User.Identity.Name);
            notation.Housing = db.HousingDB.First(h => h.ID == notationPost.HousingID);

            db.NotationDB.Add(notation);
            await db.SaveChangesAsync();

            return(Created("api/Notations/" + notation.ID, notation));
            //return CreatedAtRoute("DefaultApi", new { id = notation.ID }, notation);
        }