Ejemplo n.º 1
0
        public async Task <ActionResult> PostSlider([FromBody] SliderViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid Data"));
            }
            var slider = new Models.Slider
            {
                CreateDate     = DateTime.Now,
                Description    = viewModel.Description,
                ImageName      = viewModel.ImageName,
                SmallImageName = viewModel.SmallImageName,
                Title          = viewModel.Title,
                IsDelete       = false,
                LastUpdateDate = DateTime.Now,
                Link           = viewModel.Link
            };

            try
            {
                await UnitOfWork.SliderRepository.Insert(slider);

                await UnitOfWork.SaveAsync();
            }
            catch (Exception e)
            {
                throw new Exception("BadRequest INsert");
            }


            return(JsonResponseStatus.Success(viewModel));
        }
    public ActionResult Sliders()
    {
        var model = new Models.Slider();

        /* ... populate model ... */

        return(PartialView("your-view-name", model));
    }
    public ActionResult Sliders()
    {
        var model = new Models.Slider();

        model = Database.Session.Query <Slider>().Where(s => s.DeletedAt == null).OrderBy(x => x.SortOrder).ToList().FirstOrDefault();

        return(PartialView("your-view-name", model));
    }
Ejemplo n.º 4
0
        public List <Models.Slider> GetSliderInfoByShopId(string ShopId)
        {
            List <Models.Slider> sliderslist = new List <Models.Slider>();
            DataTable            dt          = new DataTable();

            try
            {
                dt = _sliderData.GetSliderInfoByShopId(ShopId);
                foreach (DataRow record in dt.Rows)
                {
                    Models.Slider slider = new Models.Slider();
                    slider.Id     = record["Id"].ToString();
                    slider.Name   = record["Name"].ToString();
                    slider.ShopId = record["ShopId"].ToString();
                    slider.Images = GetAllImagesBySliderId(record["Id"].ToString()); //Build images for slider
                    sliderslist.Add(slider);
                }
            }
            catch (Exception)
            {
            }
            return(sliderslist);
        }