示例#1
0
        public ActionResult Delete(int id)
        {
            var entity = _fileMgmt.GetById(id);

            if (entity == null || string.IsNullOrEmpty(entity.Path))
            {
                return(NotFound("文件不存在"));
            }

            _fileMgmt.Delete(entity);
            _fileMgmt.Save();

            string filePath = _hostingEnvironment.WebRootPath + @"/" + entity.Path;

            if (!System.IO.File.Exists(filePath))
            {
                return(RedirectToAction("List"));
            }

            System.IO.File.Delete(filePath);



            return(RedirectToAction("List"));
        }
        public IActionResult Edit(int id = 0)
        {
            AccountModel model = new AccountModel();

            if (id == 0)
            {
                model.Password = "******";
                return(View(model));
            }


            var entity = _account.GetById(id);

            if (entity == null)
            {
                model.Password = "******";
                return(View(model));
            }

            model.Id        = entity.Id;
            model.Age       = entity.Age;
            model.Name      = entity.Name;
            model.Remark    = entity.Remark;
            model.LoginName = entity.LoginName;

            return(View(model));
        }