public JsonSonuc yapilacakDuzenle(string url, int firma_id, HttpRequestBase Request) { try { vrlfgysdbEntities db = new vrlfgysdbEntities(); yapilacaklar dbPrj = db.yapilacaklar.Where(e => e.url.Equals(url) && e.flag != durumlar.silindi).FirstOrDefault(); if (dbPrj == null || url == null || url.Equals("")) { return(yeniYapilacak(firma_id, Request)); } else if (!(dbPrj.flag != durumlar.silindi)) { return(JsonSonuc.sonucUret(false, "İşlem sırasında bir hata oluştu. Lütfen tekrar deneyiniz.")); } string urlTemp = dbPrj.url; foreach (var property in dbPrj.GetType().GetProperties()) { try { var response = Request[property.Name]; if (response == null) { if (response == null) { continue; } } else { PropertyInfo propertyS = dbPrj.GetType().GetProperty(property.Name); if (property.PropertyType == typeof(decimal)) { propertyS.SetValue(dbPrj, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null); } else { propertyS.SetValue(dbPrj, Convert.ChangeType(response, property.PropertyType), null); } } } catch (Exception) { } } dbPrj.url = urlTemp; db.Entry(dbPrj).State = EntityState.Modified; db.SaveChanges(); return(JsonSonuc.sonucUret(true, dbPrj.url)); } catch (Exception e) { return(JsonSonuc.sonucUret(false, "İşlem sırasında bir hata oluştu. Lütfen tekrar deneyiniz.")); } }
public JsonSonuc yeniYapilacak(int firma_id, HttpRequestBase Request) { try { vrlfgysdbEntities db = new vrlfgysdbEntities(); yapilacaklar yplck = new yapilacaklar(); foreach (var property in yplck.GetType().GetProperties()) { try { var response = Request[property.Name]; if (response == null && property.PropertyType != typeof(int)) { if (response == null) { continue; } } else { PropertyInfo propertyS = yplck.GetType().GetProperty(property.Name); if (property.PropertyType == typeof(decimal)) { propertyS.SetValue(yplck, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null); } else if (property.PropertyType == typeof(int)) { if (response == null) { propertyS.SetValue(yplck, Convert.ChangeType(0, property.PropertyType), null); } else { propertyS.SetValue(yplck, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null); } } else { propertyS.SetValue(yplck, Convert.ChangeType(response, property.PropertyType), null); } } } catch (Exception) { } } yplck.firma_id = firma_id; yplck.tamamlanma_tarihi = DateTime.Now; yplck.flag = durumlar.aktif; yplck.date = DateTime.Now; yplck.ekleyen = GetCurrentUser.GetUser().id; yplck.durum = YapilacaklarDurum.beklemede; return(yapilacakEkle(yplck)); } catch (Exception e) { return(JsonSonuc.sonucUret(false, "İşlem sırasında bir hata oluştu. Lütfen tekrar deneyiniz.")); } }