I'm trying to post the TalimatGorevModelmobile model to the TalimatGorevEkleService() method, but every time talimatGorevPost = null.for post processing:
I used WebInvoke but in TalimatGorevEkleService method talimatGorevModelmobil returns null
[OperationContract] [WebInvoke(Method = "POST",UriTemplate = "/TalimatGorevEkleService", BodyStyle = WebMessageBodyStyle.Wrapped)] //int TalimatGorevEkleService( string talimat, string talimatGorev, DateTime sonTarih, int[] list, string token ); string TalimatGorevEkleService(TalimatGorevModelmobil talimatGorevModelmobil);
TalimatGorevEkle.xaml.cs:
public void GorevEkle(object sender, EventArgs e)
{
//var deneme = OnCollectionViewSelectionChanged();
TalimatGorevModelmobil talimatGorevPost = new TalimatGorevModelmobil();
//var jsonValue = JsonConvert.SerializeObject(kullaniciList);
talimatGorevPost.GorevliListe = kullaniciList;
talimatGorevPost.TalimatBaslik = talimatAdi.Text;
talimatGorevPost.TalimatGorevAdi = talimatGörevAdi.Text;
talimatGorevPost.SonTarih = gorevSonTarih.Date;
string durum = Methodlar.TalimatGorevEkleAsync(talimatGorevPost, Sabitler.Token).Result;
if (!string.IsNullOrEmpty(durum))
{
var a = new NotificationOptions() { Title = "Uyarı", Description = durum, IsClickable = false, AllowTapInNotificationCenter = true, ClearFromHistory = true };
App.notificator.Notify(a);
}
else
{
var a = new NotificationOptions() { Title = "Bilgilendirme", Description = "Gorev kayıt edilmiştir.", IsClickable = false, AllowTapInNotificationCenter = true, ClearFromHistory = true };
App.notificator.Notify(a);
}
}
Methodlar.cs:
public static async Task<string> TalimatGorevEkleAsync( TalimatGorevModelmobil talimatGorevPost, string token)
{
var client = new HttpClient();
var json = JsonConvert.SerializeObject(talimatGorevPost);
var stringContent = new StringContent(json, Encoding.UTF8 ,"application/json");
//var json = JsonConvert.SerializeObject(talimatGorevPost);
//string url = Sabitler.Service_Url + "/TalimatGorevEkleService?talimat=" + talimat + "&talimatGorev=" + talimatgorev + "&sonTarih=" + sonTarih + "&list=" + list + "&token=" + token;
//string url = Sabitler.Service_Url + "/TalimatGorevEkleService?talimatGorevPost=" + talimatGorevPost + "&token=" + token;
var url = await client.PostAsync(Sabitler.Service_Url + "/TalimatGorevEkleService", stringContent);
var responseString = await url.Content.ReadAsStringAsync();
return responseString;
}
Service:
public int TalimatGorevEkleService(TalimatGorevModelmobil talimatGorevPost)
{
TalepTakipDBEntities db = new TalepTakipDBEntities();
//KullaniciToken kt = KulListe.FirstOrDefault(l => l.Token == token);
//if (kt == null)
// return (int)Sabit.SistemDurumlar.TokenSureDoldu;
tbl_Talimat newTalimat = new tbl_Talimat();
newTalimat.Baslik = talimatGorevPost.TalimatBaslik;
if (newTalimat.ID == 0)
{
// newTalimat.IslemKulID = kt.ID;
newTalimat.isGenel = true;
//talimat.GrupID = kt.GrupID.Value;
newTalimat.EklenmeTarihi = DateTime.Now;
db.tbl_Talimat.Add(newTalimat);
}
try
{
db.SaveChanges();
}
catch (Exception ex)
{
Fonksiyonlar.HataEkle(ex);
//return Redirect(Request.UrlReferrer.AbsoluteUri);
}
tbl_TalimatGorev grv = new tbl_TalimatGorev();
grv.SonTarih = talimatGorevPost.SonTarih;
grv.Baslik = talimatGorevPost.TalimatGorevAdi;
if (grv.ID == 0)
{
//grv.IslemKulID = kt.ID;
grv.EklenmeTarihi = DateTime.Now;
grv.DurumID = (int)Sabitler.TalimatSurecTur.Bekliyor;
grv.TalimatID = newTalimat.ID;
db.tbl_TalimatGorev.Add(grv);
}
try
{
db.SaveChanges();
}
catch (Exception ex)
{
Fonksiyonlar.HataEkle(ex);
}
if (talimatGorevPost.GorevliListe != null && talimatGorevPost.GorevliListe.Any())
{
tbl_TalimatGorevSurec src = new tbl_TalimatGorevSurec();
//src = YeniSurecEkle(grv, "", (int)Sabitler.TalimatSurecTur.Yonlendirme, kullaniciList);
}
return (int)Sabit.SistemDurumlar.Olumlu;
}
talimatGorevPost = null