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) { } }
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)); } }
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); }
public static bool CheckIsBlocked() { using (TageerEntities db = new TageerEntities()) { int UserId = AccessToken.GetUserId(); return(db.Users.Find(UserId).IsBlocked); } }
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); }
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); }
//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; }
public DeleteService(TageerEntities db, List <string> filesRemove) { this.db = db; FilesRemove = filesRemove; }
public CreateService(TageerEntities db) { this.db = db; }
public UpdateService(TageerEntities _db) { this.CheckedS = new CheckedService(_db); this.db = _db; }