コード例 #1
0
        public async Task <IActionResult> Create(CMSViewModels item, IFormFile FileUploadId)
        {
            var content = "";

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

            if (item.HtmlType == 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.MenuItems = new SelectList(new MenuItemManager().GetAll(), "ItemId", "Name");
            ViewBag.HtmlTypes = 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 CMSManager().GetById(item.Id);
                        item.Content = oldItem.Content;
                    }
                    new CMSManager().Update(new CMSViewModels().Transform(item));
                }
                else
                {
                    new CMSManager().Create(new CMSViewModels().Transform(item));
                }

                return(RedirectToAction("Index"));
            }
            return(View(item));
        }
コード例 #2
0
        private string GetDeptId(string UserId, string Role)
        {
            CMSManager cms = new CMSManager();

            if (Role.Equals("Admin") || Role.Equals("Client") || Role.Equals("Administrator"))
            {
                return(cms.GetCorporateProfile(UserId).FirstOrDefault().DepartmentId);
            }

            return(string.Empty);
        }
コード例 #3
0
        public JsonResult DeleteItem(int ItemId)
        {
            var _cmsItemManager = new CMSManager();
            var item            = _cmsItemManager.GetById(ItemId);

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

                return(Json(true));
            }
            else
            {
                return(Json(false));
            }
        }
コード例 #4
0
        public string GetUserName(string UserId, string Role)
        {
            CMSManager cms       = new CMSManager();
            EMSManager ems       = new EMSManager();
            Student    candidate = new Student();

            if (Role.Equals("Admin") || Role.Equals("Client") || Role.Equals("Administrator"))
            {
                return(cms.GetUserName(UserId));
            }
            else if (Role.Equals("Employee"))
            {
                return(ems.GetUserName(UserId));
            }
            else if (Role.Equals("Candidate"))
            {
                return(candidate.GetUserName(UserId));
            }

            return(string.Empty);
        }
コード例 #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));
        }
コード例 #6
0
        public IActionResult Index()
        {
            var all = new CMSManager().GetAll();

            return(View(all));
        }
コード例 #7
0
        public JsonResult GetAll()
        {
            var all = new CMSManager().GetAll();

            return(Json(new { data = all }));
        }