public string musteriDuzenle(string url, int firma_id, HttpRequestBase Request) { try { vrlfgysdbEntities db = new vrlfgysdbEntities(); musteriler dbMstr = db.musteriler.Where(e => e.url.Equals(url) && e.flag != durumlar.silindi).FirstOrDefault(); if (dbMstr == null || url == null || url.Equals("")) { return(yeniMusteri(firma_id, Request)); } else if (!(dbMstr.flag != durumlar.silindi)) { return(""); } string urlTemp = dbMstr.url; foreach (var property in dbMstr.GetType().GetProperties()) { try { var response = Request[property.Name]; if (response == null) { if (response == null) { continue; } } else { PropertyInfo propertyS = dbMstr.GetType().GetProperty(property.Name); if (property.PropertyType == typeof(decimal)) { propertyS.SetValue(dbMstr, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null); } else { propertyS.SetValue(dbMstr, Convert.ChangeType(response, property.PropertyType), null); } } } catch (Exception) { } } dbMstr.url = urlTemp; bool kullaniciKontrol = firmaMusteriKontrol(dbMstr.firma_id, dbMstr.id).Result; if (!kullaniciKontrol) { return("musteri_sayisi_hatasi"); } db.Entry(dbMstr).State = EntityState.Modified; db.SaveChanges(); if (dbMstr.id == GetCurrentUser.GetUser().id) { kullaniciIslemleri ki = new kullaniciIslemleri(); ki.resetLoginInfo(); } return(dbMstr.url); } catch (Exception e) { return(""); } }
public string kullaniciDuzenle(string url, string password, string password_control, string mail_permission, string sms_permission, HttpRequestBase Request) { try { vrlfgysdbEntities db = new vrlfgysdbEntities(); int mailPermission = Permissions.granted; if (mail_permission == null) { mailPermission = Permissions.denied; } int smsPermission = Permissions.granted; if (sms_permission == null) { smsPermission = Permissions.denied; } LoggedUserModel lgm = GetCurrentUser.GetUser(); int incelenecekKullaniciTurleri = lgm.kullanici_turu; if (lgm.kullanici_turu == KullaniciTurleri.super_admin) { incelenecekKullaniciTurleri = 0; } kullanicilar dbUser = db.kullanicilar.Where(e => e.url.Equals(url) && e.flag != durumlar.silindi && (e.id == lgm.id || e.kullanici_turu > incelenecekKullaniciTurleri)).FirstOrDefault(); if (dbUser == null || url == null || url.Equals("")) { string firmaId = Request["firma_id"].ToString(); if (!firmaId.Equals(lgm.firma_id.ToString())) { return(""); } return(yeniKullanici(password, password_control, mail_permission, sms_permission, Request)); } else if (!(dbUser.flag != durumlar.silindi)) { return(""); } string passwordTemp = dbUser.password; string urlTemp = dbUser.url; //kullanicilar user = new kullanicilar(); foreach (var property in dbUser.GetType().GetProperties()) { try { var response = Request[property.Name]; if (response == null) { if (response == null) { continue; } } else { PropertyInfo propertyS = dbUser.GetType().GetProperty(property.Name); if (property.PropertyType == typeof(decimal)) { propertyS.SetValue(dbUser, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null); } else { propertyS.SetValue(dbUser, Convert.ChangeType(response, property.PropertyType), null); } } } catch (Exception) { } } if (!password.Trim().Equals("")) { dbUser.password = HashWithSha.ComputeHash(password, "SHA512", Encoding.ASCII.GetBytes(password)); } else { dbUser.password = passwordTemp; } dbUser.url = urlTemp; if (!(dbUser.id == lgm.id || dbUser.kullanici_turu > incelenecekKullaniciTurleri)) { return(""); } bool kullaniciKontrol = firmaKullaniciKontrol(dbUser.firma_id, dbUser.id).Result; if (!kullaniciKontrol) { return("kullanici_sayisi_hatasi"); } dbUser.mail_permission = mailPermission; dbUser.sms_permission = smsPermission; db.Entry(dbUser).State = EntityState.Modified; db.SaveChanges(); if (dbUser.id == GetCurrentUser.GetUser().id) { kullaniciIslemleri ki = new kullaniciIslemleri(); ki.resetLoginInfo(); } return(dbUser.url); } catch (Exception e) { if (e.InnerException != null && e.InnerException.ToString().Contains("email_unique")) { return("email_unique"); } else if (e.InnerException != null && e.InnerException.ToString().Contains("username_unique")) { return("username_unique"); } else { return(""); } } }
public string firmaMusavirDuzenle(string url, HttpRequestBase Request) { try { vrlfgysdbEntities db = new vrlfgysdbEntities(); firma_musavir dbfm = db.firma_musavir.Where(e => e.url.Equals(url)).FirstOrDefault(); string dbUrlTemp = dbfm.url; //firma_musavir fm = new firma_musavir(); foreach (var property in dbfm.GetType().GetProperties()) { try { var response = Request[property.Name]; if (response == null) { if (response == null) { continue; } } else { PropertyInfo propertyS = dbfm.GetType().GetProperty(property.Name); if (property.PropertyType == typeof(decimal)) { propertyS.SetValue(dbfm, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null); } else { propertyS.SetValue(dbfm, Convert.ChangeType(response, property.PropertyType), null); } } } catch (Exception) { } } dbfm.url = dbUrlTemp; db.Entry(dbfm).State = EntityState.Modified; db.SaveChanges(); if (dbfm.id == GetCurrentUser.GetUser().firma_id) { kullaniciIslemleri ki = new kullaniciIslemleri(); ki.resetLoginInfo(); } return(dbfm.url); } catch (Exception e) { if (e.InnerException != null && e.InnerException.ToString().Contains("email_unique")) { return("email_unique"); } else { return(""); } } }