Ejemplo n.º 1
0
        public static async Task <bool> firmaProjeKontrol(int firma_id, int musteri_id)
        {
            vrlfgysdbEntities db = new vrlfgysdbEntities();

            if (firma_id == 0)
            {
                return(true);
            }
            var    f = db.firma_musavir.Where(e => e.flag == durumlar.aktif && e.id == firma_id).FirstOrDefaultAsync();
            string queryMusteriCount = "select count(id) from proje_surec where tur = " + ProjeSurecTur.proje + " and flag != " + durumlar.silindi.ToString() + " and firma_id = " + firma_id.ToString() + " and id != " + musteri_id;
            var    kc = db.Database.SqlQuery <int>(queryMusteriCount).FirstOrDefaultAsync();

            await Task.WhenAll(f, kc);

            firma_musavir fm         = f.Result;
            int           projeCount = kc.Result;

            if (fm == null)
            {
                return(false);
            }
            else if (fm.proje_sayisi > projeCount)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public JsonResult silFirmaMusavir(string id)
        {
            try
            {
                firma_musavir fm = db.firma_musavir.Where(e => e.url.Equals(id)).FirstOrDefault();
                if (fm == null)
                {
                    return(Json(FormReturnTypes.basarisiz, JsonRequestBehavior.AllowGet));
                }
                fm.flag            = durumlar.silindi;
                db.Entry(fm).State = EntityState.Modified;

                if (fm.id == GetCurrentUser.GetUser().firma_id)
                {
                    kullaniciIslemleri ki = new kullaniciIslemleri();
                    ki.resetLoginInfo();
                }
                db.SaveChanges();
            }
            catch (Exception)
            {
                return(Json(FormReturnTypes.basarisiz, JsonRequestBehavior.AllowGet));
            }
            return(Json(FormReturnTypes.basarili, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        } // End Sub SetAuthCookie

        public static async Task <bool> firmaKullaniciKontrol(int firma_id, int user_id)
        {
            vrlfgysdbEntities db = new vrlfgysdbEntities();

            if (firma_id == 0)
            {
                return(true);
            }

            /*if (user_id == 0)
             * {
             *  var f = db.firma_musavir.Where(e => e.flag == durumlar.aktif && e.id == firma_id).FirstOrDefaultAsync();
             *  string queryKullaniciCount = "select count(id) from firma_musavir where flag = " + durumlar.aktif.ToString() + " and firma_id = " + firma_id.ToString();
             *  var kc = db.Database.SqlQuery<int>(queryKullaniciCount).FirstOrDefaultAsync();
             *
             *  await Task.WhenAll(f, kc);
             *
             *  firma_musavir fm = f.Result;
             *  int kullaniciCount = kc.Result;
             *
             *  if (fm == null)
             *  {
             *      return false;
             *  }
             *  else if(fm.kullanici_sayisi < kullaniciCount)
             *  {
             *      return true;
             *  }
             *  else
             *  {
             *      return false;
             *  }
             * }
             * else
             * {*/
            var    f = db.firma_musavir.Where(e => e.flag == durumlar.aktif && e.id == firma_id).FirstOrDefaultAsync();
            string queryKullaniciCount = "select count(id) from kullanicilar where (flag = " + durumlar.emailOnayBekliyor.ToString() + " or flag = " + durumlar.aktif.ToString() + ") and firma_id = " + firma_id.ToString() + " and id != " + user_id;
            var    kc = db.Database.SqlQuery <int>(queryKullaniciCount).FirstOrDefaultAsync();

            await Task.WhenAll(f, kc);

            firma_musavir fm             = f.Result;
            int           kullaniciCount = kc.Result;

            if (fm == null)
            {
                return(false);
            }
            else if (fm.kullanici_sayisi > kullaniciCount)
            {
                return(true);
            }
            else
            {
                return(false);
            }
            //}
        }
Ejemplo n.º 4
0
        public ActionResult firmaMusavirDuzenle(string id)
        {
            try
            {
                firma_musavir fm = db.firma_musavir.Where(e => e.url.Equals(id)).FirstOrDefault();
                if (fm == null)
                {
                    return(RedirectToAction("Index"));
                }

                return(View(fm));
            }
            catch (Exception)
            {
                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> GorevBilgisi(string id)
        {
            LoggedUserModel lgm = GetCurrentUser.GetUser();

            List <object> nesneler = new List <object>();

            var g = db.gorevler.Where(e => e.flag != durumlar.silindi && e.url.Equals(id)).FirstOrDefaultAsync();
            vrlfgysdbEntities db2 = new vrlfgysdbEntities();
            var ml = db2.musteriler.Where(e => e.flag == durumlar.aktif).ToListAsync();
            vrlfgysdbEntities db3 = new vrlfgysdbEntities();
            var kl = db3.kullanicilar.Where(e => e.flag == durumlar.aktif).ToListAsync();
            vrlfgysdbEntities db4 = new vrlfgysdbEntities();
            var p = db4.proje_surec.Where(e => e.flag == durumlar.aktif && e.tur == ProjeSurecTur.proje).ToListAsync();
            vrlfgysdbEntities db5 = new vrlfgysdbEntities();
            var s = db5.proje_surec.Where(e => e.flag == durumlar.aktif && e.tur == ProjeSurecTur.surec).ToListAsync();

            await Task.WhenAll(g, ml, kl, p, s);

            var grv = g.Result;
            List <musteriler> musteriList = ml.Result;

            if (grv == null)
            {
                grv = new gorevler();
                grv.baslangic_tarihi = DateTime.Now;
                grv.bitis_tarihi     = DateTime.Now.AddMonths(1);
            }

            List <kullanicilar> kullaniciList = kl.Result;

            nesneler.Add(grv);
            nesneler.Add(p.Result);
            nesneler.Add(s.Result);
            nesneler.Add(musteriList);
            if (lgm.kullanici_turu == KullaniciTurleri.super_admin || lgm.kullanici_turu == KullaniciTurleri.firma_admin || lgm.kullanici_turu == KullaniciTurleri.firma_yetkili)
            {
                nesneler.Add(kullaniciList);
            }
            else
            {
                nesneler.Add(null);
            }
            vrlfgysdbEntities db6 = new vrlfgysdbEntities();
            var ytk = db6.kullanici_gorev.Where(e => e.flag == durumlar.aktif && e.gorev_id == grv.id && e.kullanici_id == lgm.id).FirstOrDefaultAsync();
            vrlfgysdbEntities db7 = new vrlfgysdbEntities();
            var gp = db7.gorev_proje.Where(e => e.flag == durumlar.aktif && e.gorev_id == grv.id).FirstOrDefaultAsync();
            vrlfgysdbEntities db8 = new vrlfgysdbEntities();
            var frm = db8.firma_musavir.Where(e => e.flag == durumlar.aktif && e.id == grv.firma_id).FirstOrDefaultAsync();

            await Task.WhenAll(ytk, gp, frm);

            kullanici_gorev kullaniciGorev = ytk.Result;
            gorev_proje     gorevProje     = gp.Result;
            firma_musavir   firma          = frm.Result;

            if (gorevProje == null)
            {
                gorevProje = new gorev_proje();
            }
            nesneler.Add(gorevProje);
            nesneler.Add(lgm);
            nesneler.Add(firma);

            return(View(nesneler));
        }
Ejemplo n.º 6
0
        public async Task <CevapModel> KullaniciLogin()
        {
            try
            {
                vrlfgysdbEntities db = new vrlfgysdbEntities();

                var             context = new HttpContextWrapper(HttpContext.Current);
                HttpRequestBase request = context.Request;

                string gelenJson;
                using (Stream receiveStream = request.InputStream)
                {
                    using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
                    {
                        gelenJson = readStream.ReadToEnd();
                    }
                }

                KullanicilarModelServis kullanici = JsonConvert.DeserializeObject <KullanicilarModelServis>(gelenJson);
                kullanici.password = HashWithSha.ComputeHash(kullanici.password, "SHA512", Encoding.ASCII.GetBytes(kullanici.password));

                kullanicilar dbKullanici = db.kullanicilar.Where(e => e.flag == durumlar.aktif && e.email.Equals(kullanici.email) && e.password.Equals(kullanici.password)).FirstOrDefault();
                if (dbKullanici == null)
                {
                    return(CreateCevap.cevapOlustur(false, "Yanlış E-mail ya da şifre. Lütfen girdiğiniz bilgileri kontrol ederek tekrar deneyiniz.", null));
                }

                KullanicilarModelServis ym = new KullanicilarModelServis();
                foreach (var property in ym.GetType().GetProperties())
                {
                    try
                    {
                        var response = dbKullanici.GetType().GetProperty(property.Name).GetValue(dbKullanici, null).ToString();
                        if (response == null && property.PropertyType != typeof(int))
                        {
                            if (response == null)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            PropertyInfo propertyS = ym.GetType().GetProperty(property.Name);
                            if (property.PropertyType == typeof(decimal))
                            {
                                propertyS.SetValue(ym, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null);
                            }
                            else if (property.PropertyType == typeof(int))
                            {
                                if (response == null)
                                {
                                    propertyS.SetValue(ym, Convert.ChangeType(0, property.PropertyType), null);
                                }
                                else
                                {
                                    propertyS.SetValue(ym, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null);
                                }
                            }
                            else
                            {
                                propertyS.SetValue(ym, Convert.ChangeType(response, property.PropertyType), null);
                            }
                        }
                    }
                    catch (Exception)
                    { }
                }
                firma_musavir fm = dbKullanici.firma_musavir.FirstOrDefault();
                if (fm != null)
                {
                    ym.konum_periyot = fm.konum_periyot;
                }
                else
                {
                    ym.konum_periyot = 1;
                }

                return(CreateCevap.cevapOlustur(true, "", ym));
            }
            catch (Exception ex)
            {
                return(CreateCevap.cevapOlustur(false, "Bir hata oluştu. Lütfen tekrar deneyiniz", null));
            }
        }
        public string yeniFirmaMusavir(HttpRequestBase Request)
        {
            try
            {
                vrlfgysdbEntities db = new vrlfgysdbEntities();

                int vid = 1;
                if (db.firma_musavir.Count() != 0)
                {
                    vid = db.firma_musavir.Max(e => e.vid) + 1;
                }
                int sort = 1;
                if (db.firma_musavir.Count() != 0)
                {
                    sort = db.firma_musavir.Max(e => e.sort) + 1;
                }

                firma_musavir fm = new firma_musavir();
                foreach (var property in fm.GetType().GetProperties())
                {
                    try
                    {
                        var response = Request[property.Name];
                        if (response == null && property.PropertyType != typeof(int))
                        {
                            if (response == null)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            PropertyInfo propertyS = fm.GetType().GetProperty(property.Name);
                            if (property.PropertyType == typeof(decimal))
                            {
                                propertyS.SetValue(fm, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null);
                            }
                            else if (property.PropertyType == typeof(int))
                            {
                                if (response == null)
                                {
                                    propertyS.SetValue(fm, Convert.ChangeType(0, property.PropertyType), null);
                                }
                                else
                                {
                                    propertyS.SetValue(fm, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null);
                                }
                            }
                            else
                            {
                                propertyS.SetValue(fm, Convert.ChangeType(response, property.PropertyType), null);
                            }
                        }
                    }
                    catch (Exception)
                    { }
                }

                string        strImageName = StringFormatter.OnlyEnglishChar(fm.firma_adi);
                string        createdUrl   = strImageName;
                string        tempUrl      = createdUrl;
                bool          bulundu      = false;
                int           i            = 0;
                firma_musavir pg           = new firma_musavir();
                do
                {
                    pg = db.firma_musavir.Where(e => e.url.Equals(tempUrl)).FirstOrDefault();
                    if (pg != null)
                    {
                        tempUrl = tempUrl + i.ToString();
                    }
                    else
                    {
                        createdUrl = tempUrl;
                        bulundu    = true;
                    }
                    i++;
                } while (!bulundu);
                fm.url = createdUrl;

                fm.flag    = durumlar.aktif;
                fm.date    = DateTime.Now;
                fm.vid     = vid;
                fm.sort    = sort;
                fm.isim    = "";
                fm.ekleyen = GetCurrentUser.GetUser().id;

                db.firma_musavir.Add(fm);
                db.SaveChanges();

                return(fm.url);
            }
            catch (Exception e)
            {
                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("");
                }
            }
        }