public ActionResult Save(SysApartModel model)
        {
            var          result = new JsonModel();
            SysApartment apart  = null;
            var          opType = OperationType.Insert;

            if (model.Id > 0)
            {
                opType = OperationType.Update;
                apart  = SysApartRepository.Get(model.Id);
                if (apart == null)
                {
                    result.msg = "找不到记录!";
                    return(Json(result));
                }
            }
            else
            {
                apart = new SysApartment();
            }
            Mapper.Map(model, apart);
            SysApartmentSvc.Save(apart, model.RoleIds);
            LogRepository.Insert(TableSource.SysApartment, opType, apart.Id);
            result.data = apart;
            result.code = JsonModelCode.Succ;
            result.msg  = "保存成功!";
            return(Json(result));
        }
Beispiel #2
0
        public async Task <ActionResult> Delete(long id)
        {
            var json = new JsonModel();
            await SysApartRepository.DeleteAsync(id);

            json.message = "删除成功!";
            return(Json(json));
        }
        public async Task <List <SysApartJsonModel> > GetJsonListAsync(long userId)
        {
            var apartList = await SysApartRepository.GetJsonList();

            var apartIdList = await User2ApartRepository.GetApartIdListAsync(userId);

            SetJsonChecked(apartIdList, apartList);

            return(apartList);
        }
        public ActionResult Delete(long id)
        {
            var result  = new JsonModel();
            var deleIds = SysApartRepository.Delete(id);

            LogRepository.Insert(TableSource.SysApartment, OperationType.Delete, deleIds);
            result.msg  = "删除成功!";
            result.code = JsonModelCode.Succ;
            return(Json(result));
        }
        public ActionResult GetApart(long id)
        {
            var result = new JsonModel();
            var apart  = SysApartRepository.Get(id);

            if (apart == null)
            {
                result.msg = "找不到记录!";
                return(Json(result));
            }
            apart.LstRoleIds = UserRole2ApartRepository.GetLstRoleId(apart.Id);
            result.data      = apart;
            result.code      = JsonModelCode.Succ;
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #6
0
        public Task <List <DropdownItemModel> > GetResListAsync(FilterCurrent curr)
        {
            IQueryable <DropdownItemModel> query = null;

            switch (curr)
            {
            case FilterCurrent.CurrentUserId:
                query = UserRepository.QueryEnable()
                        .OrderByDescending(m => m.Id)
                        .Select(m => new DropdownItemModel()
                {
                    Value = m.Id,
                    Text  = m.LoginName
                });
                break;

            case FilterCurrent.CurrentRoleId:
                query = UserRoleRepository.QueryEnable()
                        .OrderBy(m => m.Sort)
                        .ThenByDescending(m => m.Id)
                        .Select(m => new DropdownItemModel()
                {
                    Value = m.Id,
                    Text  = m.Name
                });
                break;

            case FilterCurrent.CurrentDeptId:
                query = SysApartRepository.QueryEnable()
                        .OrderBy(m => m.Sort)
                        .ThenByDescending(m => m.Id)
                        .Select(m => new DropdownItemModel()
                {
                    Value = m.Id,
                    Text  = m.Name
                });
                break;

            default:
                break;
            }
            return(query.ToListAsync());
        }
Beispiel #7
0
        public async Task <ActionResult> Save(SysApartModel model)
        {
            var result = new JsonModel();

            if (!ModelState.IsValid)
            {
                result.GetError(ModelState);
                return(Json(result));
            }
            SysApartment apart         = null;
            var          operationType = OperationType.Insert;

            if (model.Id > 0)
            {
                operationType = OperationType.Update;
                apart         = await SysApartRepository.GetEnableByIdAsync(model.Id);

                if (apart == null)
                {
                    result.statusCode = 300;
                    result.message    = "该条数据不存在,请刷新重试!";
                    return(Json(result));
                }
            }
            else
            {
                apart = new SysApartment();
            }
            apart = Mapper.Map(model, apart);
            apart.CommonStatus = CommonStatus.Enabled;
            await SysApartRepository.SaveAsync(apart);

            await LogRepository.Insert(TableSource.SysApartments, operationType, "", apart.Id);

            apart.IndexOfParent = await SysApartmentRepository.GetIndexOfParent(apart);

            result.Data    = apart;
            result.message = "保存成功!";
            return(Json(result));
        }
Beispiel #8
0
        public void Save(SysApartment apart, long[] lstRoleIds)
        {
            SysApartRepository.Save(apart);

            UserRole2ApartRepository.SaveList(apart.Id, lstRoleIds);
        }
Beispiel #9
0
        public async Task <ActionResult> Index()
        {
            var data = await SysApartRepository.GetJsonList();

            return(PartialView("Index", JsonConvert.SerializeObject(data)));
        }
        public ActionResult GetJsonList()
        {
            var list = SysApartRepository.GetJsonList();

            return(Json(list, JsonRequestBehavior.AllowGet));
        }