コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }