public static bool IsUserInRole(string userId, string[] roles) { using (var db = new SignageDigitalEntities()) { return db.AspNetUsers.Any(e => e.Id == userId && e.AspNetRoles.Any(i => roles.Contains(i.Name))); } }
public static object GetChannels(SignageDigitalEntities db) { return db.Channel.Select(e => new ComboBoxModel { IdLg = e.ChannelId, Value = e.Name }).ToList(); }
public static List<ComboBoxModel> GetLstMedias(SignageDigitalEntities db) { return db.Media.Select(e => new ComboBoxModel { IdLg = e.MediaId, Value = "( " + e.CatMime.Mime.ToUpper() + " ) " + e.LogicName }).ToList(); }
public static Dictionary<string, MimeListModel> GetMimeTypes() { using (var db = new SignageDigitalEntities()) { return db.CatMime.Where(e => e.IsObsolete == false). Select(e => new {e.Mime, e.CatMimeId, LstExt = e.CatMimeExtension.Select(i => i.Extension).ToList()}). ToDictionary(e => e.Mime, e => new MimeListModel { CatMimeId = e.CatMimeId, LstMimes = e.LstExt }); } }
public void Dispose() { try { if (Db != null) Db.Dispose(); } catch (Exception) { return; } finally { Db = null; } }
public static List<ComboBoxModel> GetScreenSize(SignageDigitalEntities db) { var lstData = db.CatScreenSize.Where(e => e.IsObsolete == false) .Select(e => new { Id = e.CatScreenSizeId, e.SizeX, e.SizeY }).ToList(); return lstData.Select(e => new ComboBoxModel { Id = e.Id, Value = new { Name = String.Format("{0} x {1}", e.SizeX, e.SizeY), e.SizeX, e.SizeY } }).ToList(); }
public ResponseMessageModel DoUpsert(SignageDigitalEntities db, Screen model) { if (model.ScreenId > 0) { var modelOld = db.Screen.Single(e => e.ScreenId == model.ScreenId); modelOld.Name = model.Name; modelOld.CatScreenSizeId = model.CatScreenSizeId; modelOld.UserId = model.UserId; modelOld.Timestamp = DateTime.Now; for (var i = modelOld.ScreenSchedule.Count-1; i >= 0; i--) { var screenOld = modelOld.ScreenSchedule.ElementAt(i); var screenNew = model.ScreenSchedule.FirstOrDefault(e => e.ScreenId == screenOld.ScreenId); if (screenNew == null) { db.ScreenSchedule.Remove(screenOld); } else { screenOld.CopyValues(screenNew); model.ScreenSchedule.Remove(screenNew); } } foreach (var screenSchedule in model.ScreenSchedule) { modelOld.ScreenSchedule.Add(screenSchedule); } } else { db.Screen.Add(model); } db.SaveChanges(); return new ResponseMessageModel { HasError = false, Title = ResShared.TITLE_REGISTER_SUCCESS, Message = ResShared.INFO_REGISTER_SAVED, }; }
public ResponseMessageModel DoUpsert(SignageDigitalEntities db, Media model) { var repository = new GenericRepository<Media>(db); if (model.MediaId == EntityConstants.NULL_VALUE) { repository.Add(model); } else { repository.Update(model); } return new ResponseMessageModel { HasError = false, Title = ResShared.TITLE_REGISTER_SUCCESS, Message = ResShared.INFO_REGISTER_SAVED }; }
public string GetChannels(SignageDigitalEntities db) { var lstInfo = CatSharedRepository.GetChannels(db); return _jSerializer.Serialize(lstInfo); }
public async Task<string> GetScreenSizeAsync(SignageDigitalEntities db) { var lstInfo = await CatSharedRepository.GetScreenSizeAsync(db); return _jSerializer.Serialize(lstInfo); }
public BaseRepository(SignageDigitalEntities db) { Db = db; }
public ChannelService(SignageDigitalEntities db) { _db = db; }