public async Task <ActionResult> SurecBilgisi(string id)
        {
            List <object> nesneler = new List <object>();

            var p  = db.proje_surec.Where(e => e.flag != durumlar.silindi && e.url.Equals(id) && e.tur == ProjeSurecTur.surec).FirstOrDefaultAsync();
            var fl = db.firma_musavir.Where(e => e.flag != durumlar.silindi).ToListAsync();

            GorevlerController hc = new GorevlerController();
            var grvl = hc.GorevleriGetir(id);

            await Task.WhenAll(p, fl, grvl);

            ViewResult grvResult = (ViewResult)grvl.Result;
            List <GorevVeProjeOzetModel> gorevList = (List <GorevVeProjeOzetModel>)(grvResult.Model);

            proje_surec prj = p.Result;

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

            List <firma_musavir> firmaList = fl.Result;


            vrlfgysdbEntities db2 = new vrlfgysdbEntities();
            var ml = db2.musteriler.Where(e => e.flag == durumlar.aktif && e.firma_id == prj.firma_id).ToListAsync();

            /*vrlfgysdbEntities db3 = new vrlfgysdbEntities();
             * var kl = db3.kullanicilar.Where(e => e.flag == durumlar.aktif && e.firma_id == prj.firma_id).ToListAsync();*/
            var pm = db.proje_musteri.Where(e => e.proje_id == prj.id && e.flag == durumlar.aktif).FirstOrDefaultAsync();

            //await Task.WhenAll(ml, kl, pm);
            await Task.WhenAll(ml, pm);

            List <musteriler> musteriList = ml.Result;

            proje_musteri pmust = pm.Result;

            if (pmust == null)
            {
                pmust = new proje_musteri();
            }

            //List<kullanicilar> kullaniciList = kl.Result;

            nesneler.Add(prj);
            nesneler.Add(musteriList);
            nesneler.Add(pmust);
            //nesneler.Add(kullaniciList);
            nesneler.Add(firmaList);
            nesneler.Add(gorevList);

            return(View(nesneler));
        }
Exemple #2
0
 public JsonSonuc projeSurecMusterisiKullaniciGorevlendir(int id, string kullanici)
 {
     try
     {
         vrlfgysdbEntities db  = new vrlfgysdbEntities();
         kullanicilar      usr = db.kullanicilar.Where(e => e.flag == durumlar.aktif && e.url.Equals(kullanici)).FirstOrDefault();
         proje_musteri     pm  = db.proje_musteri.Where(e => e.id.Equals(id)).FirstOrDefault();
         if (usr == null)
         {
             pm.kullanici_id = 0;
         }
         else
         {
             pm.kullanici_id = usr.id;
         }
         db.Entry(pm).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception)
     {
         return(JsonSonuc.sonucUret(false, "İşlem sırasında bir hata oluştu. Lütfen tekrar deneyiniz."));
     }
     return(JsonSonuc.sonucUret(true, "Kullanıcı yetkilendirildi."));
 }
Exemple #3
0
        public JsonSonuc yeniProjeMusterisi(HttpRequestBase Request, string[] musteriList)
        {
            try
            {
                vrlfgysdbEntities db = new vrlfgysdbEntities();

                foreach (string str in musteriList)
                {
                    int vid = 1;
                    if (db.proje_musteri.Count() != 0)
                    {
                        vid = db.proje_musteri.Max(e => e.vid) + 1;
                    }
                    int sort = 1;
                    if (db.proje_musteri.Count() != 0)
                    {
                        sort = db.proje_musteri.Max(e => e.sort) + 1;
                    }

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

                    pm.flag       = durumlar.aktif;
                    pm.date       = DateTime.Now;
                    pm.vid        = vid;
                    pm.sort       = sort;
                    pm.ekleyen    = GetCurrentUser.GetUser().id;
                    pm.musteri_id = Convert.ToInt32(str);

                    proje_musteri dbPm = db.proje_musteri.Where(e => e.flag == durumlar.aktif && e.proje_id == pm.proje_id && e.musteri_id == pm.musteri_id).FirstOrDefault();
                    if (dbPm != null)
                    {
                        continue;
                        //return JsonSonuc.sonucUret(true, "Müşteri Eklendi.");
                    }

                    db.proje_musteri.Add(pm);
                    db.SaveChanges();
                }

                return(JsonSonuc.sonucUret(true, "Müşteri Eklendi."));
            }
            catch (Exception e)
            {
                return(JsonSonuc.sonucUret(false, "İşlem sırasında bir hata oluştu. Lütfen tekrar deneyiniz."));
            }
        }