Example #1
0
        public void KullaniciYetkiEkle(KullaniciYetkiDTO entity)
        {
            KullaniciYetki kullaniciYetki = new KullaniciYetki
            {
                KullaniciYetkisi = entity.KullaniciYetkisi
            };

            kullaniciYetkiRepository.Ekle(kullaniciYetki);
            kullaniciYetkiRepository.Context.SaveChanges();
        }
        public ActionResult EkleGuncelle(string Adi, string Soyadi, string Parola, string Email, int[] chkIds, int ID = 0)
        {
            if (ID != 0)
            {
                _kullanici      = _kullaniciBLL.GetById(ID);
                ViewBag.kontrol = kullaniciYetkiBLL.Get(x => x.KullaniciID == _kullanici.ID).ToList();

                foreach (var item in _kullanici.KullaniciYetki)
                {
                    KullaniciYetki yenikullaniciYetki = new KullaniciYetki();
                    yenikullaniciYetki = kullaniciYetkiBLL.GetById(item.ID);
                    kullaniciYetkiBLL.Delete(yenikullaniciYetki);
                }


                foreach (var item in chkIds)
                {
                    KullaniciYetki yenikullaniciYetki = new KullaniciYetki();
                    yenikullaniciYetki.KullaniciID = _kullanici.ID;
                    yenikullaniciYetki.YetkiID     = item;
                    kullaniciYetkiBLL.Insert(yenikullaniciYetki);
                }
                _kullanici.Adi    = Adi;
                _kullanici.Soyadi = Soyadi;
                _kullanici.Tarih  = DateTime.Now;
                _kullaniciBLL.InsertOrUpdate(_kullanici, ID);
                ViewBag.kontrol = kullaniciYetkiBLL.Get(x => x.KullaniciID == _kullanici.ID).ToList();
                return(View(_kullanici));
            }
            else
            {
                _kullanici.Adi    = Adi;
                _kullanici.Soyadi = Soyadi;
                _kullanici.Parola = Parola;
                _kullanici.Email  = Email;
                _kullaniciBLL.InsertOrUpdate(_kullanici, ID);

                foreach (var item in chkIds)
                {
                    KullaniciYetki yenikullaniciYetki = new KullaniciYetki();
                    yenikullaniciYetki.KullaniciID = _kullanici.ID;
                    yenikullaniciYetki.YetkiID     = item;
                    kullaniciYetkiBLL.Insert(yenikullaniciYetki);
                }
                ViewBag.kontrol = kullaniciYetkiBLL.Get(x => x.KullaniciID == _kullanici.ID).ToList();
                return(View(_kullanici));
            }
        }
        public KullaniciYetki kullaniciYetkisiniGetir(long carikart_id, string apiUrl, ref string errorMessage)
        {
            KullaniciYetki kullaniciYetki = null;

            #region Query
            string query = @"
                        SELECT * FROM [dbo].[GetKullaniciYetki]('URETIM', @carikart_id)
                        Where url = @url 
                        ";
            #endregion

            #region Parameters
            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@carikart_id", carikart_id),
                new SqlParameter("@url", apiUrl)
            };
            #endregion

            try
            {
                dt = SqlHelper.ExecuteDataset(ConnectionStrings.SqlConn, CommandType.Text, query, parameters).Tables[0];

                if (dt != null && dt.Rows.Count > 0)
                {
                    kullaniciYetki            = new KullaniciYetki();
                    kullaniciYetki.modul      = dt.Rows[0]["modul"].acekaToString();
                    kullaniciYetki.url        = dt.Rows[0]["url"].acekaToString();
                    kullaniciYetki.yetkialani = dt.Rows[0]["yetkialani"].acekaToString();
                    kullaniciYetki.tanim      = dt.Rows[0]["tanim"].acekaToString();
                    kullaniciYetki.okuma      = dt.Rows[0]["okuma"].acekaToBool();
                    kullaniciYetki.yazma      = dt.Rows[0]["yazma"].acekaToBool();
                    kullaniciYetki.silme      = dt.Rows[0]["silme"].acekaToBool();

                    kullaniciYetki.ozel1  = dt.Rows[0]["ozel1"].acekaToBool();
                    kullaniciYetki.ozel2  = dt.Rows[0]["ozel2"].acekaToBool();
                    kullaniciYetki.ozel3  = dt.Rows[0]["ozel3"].acekaToBool();
                    kullaniciYetki.ozel4  = dt.Rows[0]["ozel4"].acekaToBool();
                    kullaniciYetki.ozel5  = dt.Rows[0]["ozel5"].acekaToBool();
                    kullaniciYetki.ozel6  = dt.Rows[0]["ozel6"].acekaToBool();
                    kullaniciYetki.ozel7  = dt.Rows[0]["ozel7"].acekaToBool();
                    kullaniciYetki.ozel8  = dt.Rows[0]["ozel8"].acekaToBool();
                    kullaniciYetki.ozel9  = dt.Rows[0]["ozel9"].acekaToBool();
                    kullaniciYetki.ozel10 = dt.Rows[0]["ozel10"].acekaToBool();
                    kullaniciYetki.ozel11 = dt.Rows[0]["ozel11"].acekaToBool();
                    kullaniciYetki.ozel12 = dt.Rows[0]["ozel12"].acekaToBool();
                    kullaniciYetki.ozel13 = dt.Rows[0]["ozel13"].acekaToBool();
                    kullaniciYetki.ozel14 = dt.Rows[0]["ozel14"].acekaToBool();
                    kullaniciYetki.ozel15 = dt.Rows[0]["ozel15"].acekaToBool();
                    kullaniciYetki.ozel16 = dt.Rows[0]["ozel16"].acekaToBool();
                    kullaniciYetki.ozel17 = dt.Rows[0]["ozel17"].acekaToBool();
                    kullaniciYetki.ozel18 = dt.Rows[0]["ozel18"].acekaToBool();
                    kullaniciYetki.ozel19 = dt.Rows[0]["ozel19"].acekaToBool();
                    kullaniciYetki.ozel20 = dt.Rows[0]["ozel20"].acekaToBool();
                }
            }
            catch (System.Exception ex)
            {
                errorMessage = ex.Message;
            }
            return(kullaniciYetki);
        }
Example #4
0
 public bool Sil(KullaniciYetki entity)
 {
     SiparisTakipContext.KullaniciYetki.Remove(entity);
     return(SiparisTakipContext.SaveChanges() > 0);
 }
Example #5
0
 public KullaniciYetki Kaydet(KullaniciYetki entity)
 {
     SiparisTakipContext.KullaniciYetki.Add(entity);
     SiparisTakipContext.SaveChanges();
     return(entity);
 }
Example #6
0
 public int Guncelle(KullaniciYetki entity)
 {
     SiparisTakipContext.KullaniciYetki.AddOrUpdate(entity);
     return(SiparisTakipContext.SaveChanges());
 }
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            //if (actionContext.Request.Method == HttpMethod.Get)
            //{

            //}

            IEnumerable <string> values = null;
            var result = actionContext.Request.Headers.TryGetValues("personel_id", out values);

            if (result == true)
            {
                var personel_id   = Convert.ToInt64(values.First().ToString());
                var requestMethod = actionContext.Request.Method;
                var endPointArr   = actionContext.Request.RequestUri.AbsolutePath.Split('/');

                /*
                 * @carikart_id","100000000100"
                 * "@url","api/stokkart"
                 */
                memberRepository = new MemberRepository();

                //Data Cache için kullanılacak
                //List<KullaniciYetki> kullaniciYetkileri = memberRepository.kullaniciYetkileriniGetir(100000000100);

                string errorMessage = "";

                KullaniciYetki kullaniciYetki = memberRepository.kullaniciYetkisiniGetir(personel_id, ApiUrl, ref errorMessage);

                if (kullaniciYetki != null && string.IsNullOrEmpty(errorMessage))
                {
                    bool authorized = false;
                    switch (requestMethod.Method.ToString())
                    {
                    case "GET":    //Okuma
                        if (kullaniciYetki.okuma)
                        {
                            authorized = true;
                        }
                        break;

                    case "POST":    //Yazma
                    case "PUT":
                        if (kullaniciYetki.yazma)
                        {
                            authorized = true;
                        }
                        break;

                    case "DELETE":     //Silme
                        if (kullaniciYetki.silme)
                        {
                            authorized = true;
                        }
                        break;
                    }

                    if (!authorized)
                    {
                        // erişim yok ise
                        //actionContext.Response = new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.Forbidden);
                    }
                }
                else
                {
                    //Eğer kullanıcıya ait herhangi bir yetkilendirme tanımlanmamış ise "Forbidden" uyarısı verilecek!

                    //actionContext.Response = new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.Forbidden);
                }
            }
            else
            {
                //actionContext.Response = new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.Forbidden);
            }


            //else
            //{
            //    var arguments = actionContext.ActionArguments;


            //    Type itemType = arguments.First().Value.GetType();
            //    if (itemType.GetProperty("kullanici_adi") != null)
            //    {
            //        var val = itemType.GetProperty("kullanici_adi").GetValue(arguments.First().Value, null);
            //    }


            //    /*degistiren_carikart_id li kullanımlarda açılacak*/
            //    //Type itemType = arguments.First().Value.GetType();
            //    //if (itemType.GetProperty("degistiren_carikart_id") != null)
            //    //{
            //    //    var carikart_id = itemType.GetProperty("degistiren_carikart_id").GetValue(arguments.First().Value, null);
            //    //}
            //}


            base.OnActionExecuting(actionContext);
        }