Esempio n. 1
0
        public static void DeleteImages(List <string> files)
        {
            try
            {
                string Path    = "/Tageer/Api/Files/Delete",
                       BaseUrl = string.Empty;

                using (TageerEntities db = new TageerEntities())
                    BaseUrl = db.AppsInformations.Find(AppInformationEnumVM.ApiFiles).Value;

                using (HttpClient HC = new HttpClient())
                {
                    JavaScriptSerializer Serializer = new JavaScriptSerializer();

                    string ObjectJson = Serializer.Serialize(files);

                    var ObjectJsonBytes = System.Text.Encoding.UTF8.GetBytes(ObjectJson);
                    var ByteContent     = new ByteArrayContent(ObjectJsonBytes);

                    //Create Header
                    HC.DefaultRequestHeaders.Accept.Clear();
                    ByteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                    HC.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    HC.BaseAddress = new Uri(BaseUrl);

                    //Call Api
                    var    Respo   = HC.PostAsync(Path, ByteContent);
                    var    Content = Respo.Result.Content;
                    string Message = Content.ReadAsStringAsync().Result;
                }
            }
            catch (Exception)
            {
            }
        }
Esempio n. 2
0
        public object Create(CommentVM commentVM)
        {
            try
            {
                AdComment Comment      = new AdComment();
                object    ObjectReturn = CreateS.Comment(commentVM, Comment);
                if (ObjectReturn != null)
                {
                    return(ObjectReturn);
                }

                db.SaveChanges();
                db      = new TageerEntities();
                Comment = db.AdComments.Find(Comment.Id);
                return(new ResponseVM(RequestTypeEnumVM.Success, Token.Created, new CommentVM
                {
                    Id = Comment.Id,
                    AdId = Comment.FKAd_Id,
                    Comment = Comment.Comment,

                    UserImage = Comment.User.Image,
                    UserName = Comment.User.UserName
                }));
            }
            catch (Exception ex)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.SomeErrorInServer, ex));
            }
        }
Esempio n. 3
0
        public override string[] GetRolesForUser(string username)
        {//الهدف من هذا الكود جلب الرول من قاعدة البيانات اذا لم توجد فى الكاش
            //واذا موجودة فى الكاش فلا داع لاجلبها من قاعدة البيانات
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                return(null);
            }

            //check cache
            var cacheKey = string.Format("{0}_role", username);//sezer_role

            if (HttpRuntime.Cache[cacheKey] != null)
            {//اذا يوجد نرجع الصلحيات من الكاش
                return((string[])HttpRuntime.Cache[cacheKey]);
            }
            //معنى ذاالك انة لا يوجد صلحيات فى الكاش ويجب جلبها من قاعدة البايانات
            string[] roles = new string[] { };
            using (TageerEntities db = new TageerEntities())
            {
                roles = db.UserRoles.Where(x => x.User.UserName == username).Select(x => x.Role.TokenValue).ToArray();
                if (roles.Count() > 0)
                {//بعد جلبهاا نقوم بحقظها فى الكاش لمدة 20 دقيقة من الان من اجل المرات القادمة
                    HttpRuntime.Cache.Insert(cacheKey, roles, null, DateTime.Now.AddMinutes(20), Cache.NoSlidingExpiration);
                }
            }
            return(roles);
        }
Esempio n. 4
0
 public static bool CheckIsBlocked()
 {
     using (TageerEntities db = new TageerEntities())
     {
         int UserId = AccessToken.GetUserId();
         return(db.Users.Find(UserId).IsBlocked);
     }
 }
Esempio n. 5
0
        public BasicBLL()
        {
            this.db           = new TageerEntities();
            this.UserService  = new UserService();
            this.AdService    = new AdsService();
            this.UserLoggadId = AccessToken.GetUserId();
            this.LangIsEn     = LanguageService.IsEn;

            this.CheckedService = new CheckedService(db);
            this.UpdateS        = new UpdateService(db);
            this.CreateS        = new CreateService(db);
        }
Esempio n. 6
0
        public static string GetCulture()
        {
            string Culture = DefaultLangage;

            if (HttpContext.Current.Request.IsAuthenticated)
            {
                using (TageerEntities db = new TageerEntities())
                    Culture = GetUserLanguage(db.Users.Find(CookieService.UserInfo.Id));
            }

            return(Culture);
        }
Esempio n. 7
0
        //Get Page Role
        public static PagesRole GetPageRole(int page)
        {
            using (TageerEntities db = new TageerEntities())
            {
                long       UserId    = CookieService.UserInfo.Id;
                List <int> UserRoles = new UserService().GetCurrentUserRoles();

                //Ceck is Role
                if (UserId == 1)
                {
                    return new PagesRole()
                           {
                               IsDisplay = true,
                               IsCreate  = true,
                               IsDelete  = true,
                               IsUpdate  = true,
                           }
                }
                ;

                /*
                 * يمكن ان يكون للمستخدم اكتر من صلاحية فبذالك يجب جلب الكل
                 */
                var PagesRole = db.PagesRoles.Where(c => c.FkPage_Id == page && c.FkUser_Id == UserId
                                                    ).First();


                /*
                 * هنا نسمح للمستخم بـ اجراء اى شىء بدام لدية موافقة فى احدى الحقول مع احدى الصلاحيات الخاصة بة
                 */
                return(new PagesRole()
                {
                    IsDisplay = PagesRole.IsDisplay,
                    IsCreate = PagesRole.IsCreate,
                    IsDelete = PagesRole.IsDelete,
                    IsUpdate = PagesRole.IsUpdate,
                });
            }
        }
    }
 public CheckedService(TageerEntities _db)
 {
     this.db = _db;
 }
Esempio n. 9
0
 public DeleteService(TageerEntities db, List <string> filesRemove)
 {
     this.db     = db;
     FilesRemove = filesRemove;
 }
Esempio n. 10
0
 public CreateService(TageerEntities db)
 {
     this.db = db;
 }
Esempio n. 11
0
 public UpdateService(TageerEntities _db)
 {
     this.CheckedS = new CheckedService(_db);
     this.db       = _db;
 }