コード例 #1
0
 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)));
     }
 }
コード例 #2
0
 public static object GetChannels(SignageDigitalEntities db)
 {
     return db.Channel.Select(e => new ComboBoxModel
     {
         IdLg = e.ChannelId,
         Value = e.Name
     }).ToList();
 }
コード例 #3
0
 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();
 }
コード例 #4
0
 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
             });
     }
 }
コード例 #5
0
 public void Dispose()
 {
     try
     {
         if (Db != null)
             Db.Dispose();
     }
     catch (Exception)
     {
         return;
     }
     finally
     {
         Db = null;
     }
 }
コード例 #6
0
        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();
        }
コード例 #7
0
        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,
            };
        }
コード例 #8
0
        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
            };
        }
コード例 #9
0
 public string GetChannels(SignageDigitalEntities db)
 {
     var lstInfo = CatSharedRepository.GetChannels(db);
     return _jSerializer.Serialize(lstInfo);
 }
コード例 #10
0
 public async Task<string> GetScreenSizeAsync(SignageDigitalEntities db)
 {
     var lstInfo = await CatSharedRepository.GetScreenSizeAsync(db);
     return _jSerializer.Serialize(lstInfo);
 }
コード例 #11
0
 public BaseRepository(SignageDigitalEntities db)
 {
     Db = db;
 }
コード例 #12
0
 public ChannelService(SignageDigitalEntities db)
 {
     _db = db;
 }