コード例 #1
0
        public JsonResult GetColors(int idpalette)
        {
            try
            {
                var colors = _context.Color.Where(c => c.IdPalette == idpalette);

                RGBColorsViewModel model = new RGBColorsViewModel(colors)
                {
                    Result = new ManipulationResult(Result.Success)
                };
                return Json(model);
            }
            catch (Exception ex)
            {
                PaletteListViewModel model = new PaletteListViewModel()
                {
                    Result = new ManipulationResult(Result.Exeption, ex)
                };
                return Json(model);
            }
        }
コード例 #2
0
        public JsonResult GetPalettes()
        {
            try
            {
                PaletteListViewModel model = new PaletteListViewModel()
                {
                    Palettes = (_context.Palette
                                .Where(p => (User == null) ? (p.IdUser == null) : ((p.IdUser == null) || (p.IdUser == User.GetUserId()))) as IEnumerable<Palette>)
                                .Select(p => new PaletteViewModel(p)),

                    Result = new ManipulationResult(Result.Success)
                };
                return Json(model);
            }
            catch (Exception ex)
            {
                PaletteListViewModel model = new PaletteListViewModel()
                {
                    Result = new ManipulationResult(Result.Exeption, ex)
                };
                return Json(model);
            }
        }
コード例 #3
0
 public JsonResult GetPalettes()
 {
     try
     {
         string id = User.GetUserId();
         PaletteListViewModel model = new PaletteListViewModel()
         {
             Palettes = _repository.PaletteRepository.GetPalettes(User.GetUserId())
                         .Select(p => new PaletteViewModel(p)),
             Result = new ManipulationResult(Result.Success)
         };
         return Json(model);
     }
     catch (Exception ex)
     {
         PaletteListViewModel model = new PaletteListViewModel()
         {
             Result = new ManipulationResult(Result.Exeption, ex)
         };
         return Json(model);
     }
 }
コード例 #4
0
        public JsonResult GetUserPalettes()
        {
            try
            {
                if (User.Identity.IsAuthenticated)
                {
                    PaletteListViewModel model = new PaletteListViewModel()
                    {
                        Palettes = _repository.PaletteRepository.GetUserPalettes(User.GetUserId())
                            .Select(p => new PaletteViewModel(p)),

                        Result = new ManipulationResult(Result.Success)
                    };
                    return Json(model);
                }
                else
                {
                    PaletteListViewModel model = new PaletteListViewModel()
                    {
                        Result = new ManipulationResult(Result.Error, "User is unauthenticated")
                    };
                    return Json(model);
                }
            }
            catch (Exception ex)
            {
                PaletteListViewModel model = new PaletteListViewModel()
                {
                    Result = new ManipulationResult(Result.Exeption, ex)
                };
                return Json(model);
            }
        }
コード例 #5
0
        public JsonResult GetPalettes()
        {
            try
            {
                if (User != null)
                {
                    PaletteListViewModel model = new PaletteListViewModel()
                    {
                        Palettes = (_context.Palette
                            .Where(p => p.IdUser == User.GetUserId()) as IEnumerable<Palette>)
                            .Select(p => new PaletteViewModel(p)),

                        Result = new ManipulationResult(Result.Success)
                    };
                    return Json(model);
                }
                else
                {
                    PaletteListViewModel model = new PaletteListViewModel()
                    {
                        Result = new ManipulationResult(Result.Error, "User is unauthenticated")
                    };
                    return Json(model);
                }
            }
            catch (Exception ex)
            {
                PaletteListViewModel model = new PaletteListViewModel()
                {
                    Result = new ManipulationResult(Result.Exeption, ex)
                };
                return Json(model);
            }
        }