Exemple #1
0
        public async Task <IActionResult> Create(CMSDetailsViewModels item, IFormFile FileUploadId)
        {
            var content = "";

            if (item.HtmlTypeId == 1)
            {
                content = item.ContentId;
            }
            else
            if (item.HtmlTypeId == 2)
            {
                content = item.TextAreaId;
            }
            else

            if (item.HtmlTypeId == 3)
            {
                content = item.HtmlEditorId;
            }
            else
            {
                if (item.FileUploadId != null)
                {
                    var filename = item.FileUploadId.FileName;
                    var path     = Path.Combine(_hostingEnvironment.WebRootPath + "\\siteimages", filename);
                    var relpath  = "/siteimages/" + filename;

                    content = relpath;
                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        await item.FileUploadId.CopyToAsync(stream);
                    }
                }
            }
            ViewBag.CMSId      = new SelectList(new CMSManager().GetAll(), "Id", "Name");
            ViewBag.HtmlTypeId = new SelectList(new HtmlTypesManager().GetAll(), "Id", "Name");
            item.Content       = content;


            if (ModelState.IsValid)
            {
                if (item.Id > 0)
                {
                    if (string.IsNullOrWhiteSpace(item.Content))
                    {
                        var oldItem = new CMSDetailsManager().GetById(item.Id);
                        item.Content = oldItem.Content;
                    }
                    new CMSDetailsManager().Update(new CMSDetailsViewModels().Transform(item));
                }
                else
                {
                    new CMSDetailsManager().Create(new CMSDetailsViewModels().Transform(item));
                }

                return(RedirectToAction("Index"));
            }
            return(View(item));
        }
Exemple #2
0
        public JsonResult GetAll(int cmsId)
        {
            var all = new List <DBModels.CMSDetails>();

            if (cmsId == 0)
            {
                all = new CMSDetailsManager().GetAll();
            }
            else
            {
                all = new CMSDetailsManager().GetByCMSId(cmsId);
            }
            return(Json(new { data = all }));
        }
Exemple #3
0
        public IActionResult Index(int cmsId)
        {
            var all = new List <DBModels.CMSDetails>();

            if (cmsId == 0)
            {
                all = new CMSDetailsManager().GetAll();
            }
            else
            {
                all = new CMSDetailsManager().GetByCMSId(cmsId);
            }
            ViewBag.cmsId = cmsId;
            return(View(all));
        }
Exemple #4
0
        public JsonResult DeleteItem(int ItemId)
        {
            var _cmsDetailsItemManager = new CMSDetailsManager();
            var item = _cmsDetailsItemManager.GetById(ItemId);

            if (item.Id > 0)
            {
                _cmsDetailsItemManager.Delete(ItemId);

                return(Json(true));
            }
            else
            {
                return(Json(false));
            }
        }
Exemple #5
0
        public IActionResult Index()
        {
            var ImportAll = new CMSManager().GetAll();

            var CMSViewModelList = new List <CMSViewModels>();

            foreach (var item in ImportAll)
            {
                var CMSViewModel = (CMSViewModels)item;
                CMSViewModel.CMSDetails = new List <CMSDetailsViewModels>();
                CMSViewModelList.Add(CMSViewModel);
                var detail = new CMSDetailsManager().GetByCMSId(item.Id);
                if (detail.Count > 0)
                {
                    foreach (var cmsDetail in detail)
                    {
                        var cms = (CMSDetailsViewModels)cmsDetail;
                        CMSViewModel.CMSDetails.Add(cms);
                    }
                }
            }
            return(View(CMSViewModelList));
        }