public async Task <SysModuleViewModel> SaveSysModule(SysModuleViewModel model)
        {
            int pnum = 0;

            if (model.ControllerName != null)
            {
                pnum = GetPurviewNum(model.ControllerName);
            }
            model.ControllerName = model.ControllerName == null ? model.ControllerName = "" : model.ControllerName;
            var entity = model.ToEntity();

            entity.Id          = SequenceQueue.NewIdString("");
            entity.CreateTime  = DateTime.Now;
            entity.Sort        = 0;
            entity.PurviewNum  = model.ControllerName == "" ? 0 : pnum + 1;
            entity.PurviewSum  = model.ControllerName == "" ? 0 : 2L << pnum;
            entity.Application = null;
            try
            {
                await _repository.AddAsync(entity);

                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw;
            }

            return(model);
        }
        public async Task <SysModuleViewModel> UpdateSysModule(SysModuleViewModel model)
        {
            var entity = await _repository.SingleAsync(a => a.Id == model.Id);

            model.ControllerName = model.ControllerName == null ? model.ControllerName = "" : model.ControllerName;
            entity = model.ToEntity(entity);
            _repository.Update(entity);
            return(model);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(SysModuleViewModel model)
        {
            if (ModelState.IsValid)
            {
                await _modulesService.UpdateSysModule(model);

                return(Redirect("/SysManager/SysModules/Index"));
            }
            return(RedirectToAction("Edit", model.Id));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create(SysModuleViewModel model)
        {
            if (ModelState.IsValid)
            {
                await _modulesService.SaveSysModule(model);

                return(Redirect("/SysManager/SysModules/Index"));
            }
            return(View());
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create()
        {
            var model = new SysModuleViewModel();

            model.ParentList = await _modulesService.ModuleItemEntities();

            model.ApplicationList = await _applicationService.AppItemEntities();

            model.AreaName = "SysManager";
            return(View(model));
        }
Exemplo n.º 6
0
        public void Update(SysModuleViewModel sysModuleViewModel)
        {
            var updateCommand = _mapper.Map <UpdateSysModuleCommand>(sysModuleViewModel);

            Bus.SendCommand(updateCommand);
        }
Exemplo n.º 7
0
        public void Instert(SysModuleViewModel sysModuleViewModel)
        {
            var createCommand = _mapper.Map <CreateNewSysModuleCommand>(sysModuleViewModel);

            Bus.SendCommand(createCommand);
        }
Exemplo n.º 8
0
 public static SysModules ToEntity(this SysModuleViewModel model, SysModules entity)
 {
     return(model.MapTo(entity));
 }
Exemplo n.º 9
0
 public static SysModules ToEntity(this SysModuleViewModel model)
 {
     return(model.MapTo <SysModuleViewModel, SysModules>());
 }