コード例 #1
0
 public void Post([FromBody] StoryAddRequest request)
 {
     if (request != null)
     {
         Console.WriteLine(request.Message);
         JObject        responseJson = JObject.Parse(request.Message);
         Message        message      = responseJson.ToObject <Message>();
         List <Contact> contacts     = db.FindContactsByEmailAndPhone(message.contact);
         if (contacts.Count != 0)
         {
             message.contact = contacts.ToList()[0];
         }
         else
         {
             db.Contacts.Add(message.contact);
         }
         message.topic = db.TopicOfMessages.Find(message.topic.id);
         db.Messages.Add(message);
         db.SaveChanges();
     }
 }