AK
Size: a a a
AK
СГ
СГ
AK
СГ
AB
AB
EA
II
СГ
public async Task<int> AddMesageApi(mRowChat Item)
{
int Item_id = 0;
string InChatName;
if (Item.avtor_name != MainActivity.mUser.User_name)
{
InChatName = Item.avtor_name;
}
else
{
InChatName = Item.recip_name;
}
var Avtor = database.QueryAsync<usr_list>( String.Format(@"SELECT id FROM usr_list WHERE usr_name = '{0}' LIMIT 1", Item.avtor_name) ).Result;
CustomClass.Log(
String.Format(
@"наш автор: {0}, а из JSON автор {1}:",
JsonConvert.SerializeObject(Avtor)
, Item.avtor_name
)
);
if (Avtor != null && Avtor.Count > 0 && Avtor[0].id > 0)
{
Item_id = Avtor[0].id;
}
else
{
usr_list InsertAvtor = new usr_list();
InsertAvtor.usr_name = Item.avtor_name;
InsertAvtor.usr_fio = Item.avtor_fio;
InsertAvtor.last_upd = DateTime.Now.ToString("s");
Item_id = DBcl.DB.SaveItemAsync(InsertAvtor).Result;
}
// добавление сообщений
usr_mes InsertMsg = new usr_mes();
InsertMsg.usr_id_avtor = Item_id;
InsertMsg.usr_mest = Item.msg_text;
InsertMsg.chat_name = InChatName;
InsertMsg.mes_date = Item.msg_date;
//InsertMsg.mes_date = DateTime.Now.ToString("o");
Item_id = await DBcl.DB.SaveMessagAsync(InsertMsg);
var Recipient = database.QueryAsync<usr_list>( String.Format(@"SELECT id FROM usr_list WHERE usr_name = '{0}' LIMIT 1", Item.recip_name) ).Result;
if (Recipient != null && Recipient.Count > 0 && Recipient[0].id > 0)
{
Item_id = Recipient[0].id;
}
else
{
usr_list InsertRecipt = new usr_list();
InsertRecipt.usr_name = Item.recip_name;
InsertRecipt.usr_fio = Item.recip_fio;
InsertRecipt.last_upd = DateTime.Now.ToString("o");
Item_id = DBcl.DB.SaveItemAsync(InsertRecipt).Result;
}
return Item_id;
}
return Item_id;
просто по фану я его не ждуII
II
II
II
СГ
MN
EA
EA