Esempio n. 1
0
 public IActionResult EditQueryView(EditQueryViewModel model)
 {
     if (ModelState.IsValid)
     {
         var entity = _queryViewFinder.FindById(model.QueryViewId);
         model.IsPrivate = entity.IsPrivate;
         model.IsDefault = entity.IsDefault;
         model.StateCode = entity.StateCode;
         model.CopyTo(entity);
         if (model.IsCustomButton && model.ButtonId.NotEmpty())
         {
             entity.CustomButtons = model.ButtonId.SerializeToJson();
         }
         else
         {
             entity.CustomButtons = string.Empty;
         }
         if (model.SaveType == "saveas")
         {
             entity.QueryViewId     = Guid.NewGuid();
             entity.IsDefault       = false;
             entity.CreatedOn       = DateTime.Now;
             entity.AggregateConfig = string.Empty;
             _queryViewCreater.Create(entity);
         }
         else
         {
             _queryViewUpdater.Update(entity);
         }
         return(UpdateSuccess(new { id = entity.QueryViewId }));
     }
     return(UpdateFailure(GetModelErrors()));
 }
Esempio n. 2
0
        public IActionResult CreateQueryView(Guid entityid)
        {
            if (entityid.Equals(Guid.Empty))
            {
                return(NotFound());
            }
            var entity = _entityFinder.FindById(entityid);

            if (entity == null)
            {
                return(NotFound());
            }
            EditQueryViewModel model = new EditQueryViewModel
            {
                SolutionId     = SolutionId.Value,
                EntityId       = entityid,
                EntityMetaData = entity,
                StateCode      = RecordState.Enabled,
                Buttons        = _ribbuttonFinder.Query(n => n
                                                        .Where(f => f.EntityId == entityid && f.StateCode == RecordState.Enabled &&
                                                               (f.ShowArea == RibbonButtonArea.ListHead || f.ShowArea == RibbonButtonArea.ListRow)))
            };

            return(View(model));
        }
Esempio n. 3
0
 public IActionResult Post(EditQueryViewModel model)
 {
     if (ModelState.IsValid)
     {
         var entity = new QueryView.Domain.QueryView();
         model.CopyTo(entity);
         entity.StateCode   = RecordState.Enabled;
         entity.IsDefault   = false;
         entity.IsPrivate   = false;
         entity.QueryViewId = Guid.NewGuid();
         entity.CreatedBy   = CurrentUser.SystemUserId;
         if (model.IsCustomButton && model.ButtonId.NotEmpty())
         {
             entity.CustomButtons = model.ButtonId.SerializeToJson();
         }
         entity.AggregateConfig = string.Empty;
         _queryViewCreater.Create(entity);
         return(CreateSuccess(new { id = entity.QueryViewId }));
     }
     return(CreateFailure(GetModelErrors()));
 }
Esempio n. 4
0
        public IActionResult EditQueryView(Guid id)
        {
            if (id.Equals(Guid.Empty))
            {
                return(NotFound());
            }
            EditQueryViewModel model = new EditQueryViewModel();
            var entity = _queryViewFinder.FindById(id);

            if (null == entity)
            {
                return(NotFound());
            }
            var entityMeta = _entityFinder.FindById(entity.EntityId);

            if (null == entityMeta)
            {
                return(NotFound());
            }
            entity.CopyTo(model);
            model.EntityMetaData = entityMeta;
            _fetchDataService.GetMetaDatas(entity.FetchConfig);
            model.EntityList      = _fetchDataService.QueryResolver.EntityList;
            model.AttributeList   = _fetchDataService.QueryResolver.AttributeList;
            model.Grid            = new GridBuilder(entity).Grid;
            model.QueryExpression = _fetchDataService.QueryExpression;
            model.Buttons         = _ribbuttonFinder.Query(n => n
                                                           .Where(f => f.EntityId == model.EntityId && f.StateCode == RecordState.Enabled &&
                                                                  (f.ShowArea == RibbonButtonArea.ListHead || f.ShowArea == RibbonButtonArea.ListRow)));
            if (model.Grid.ClientResources.NotEmpty())
            {
                model.WebResources = _webResourceFinder.Query(x => x.Select(s => new { s.WebResourceId, s.Name }).Where(f => f.WebResourceId.In(model.Grid.ClientResources)));
            }
            if (model.IsCustomButton && entity.CustomButtons.IsNotEmpty())
            {
                model.ButtonId = model.ButtonId.DeserializeFromJson(entity.CustomButtons);
            }
            return(View(model));
        }
Esempio n. 5
0
        public IActionResult Get(Guid entityid)
        {
            if (entityid.Equals(Guid.Empty))
            {
                return(NotFound());
            }
            var entity = _entityFinder.FindById(entityid);

            if (entity == null)
            {
                return(NotFound());
            }
            EditQueryViewModel model = new EditQueryViewModel();

            model.SolutionId     = SolutionId.Value;
            model.EntityId       = entityid;
            model.EntityMetaData = entity;
            model.IsDisabled     = false;
            model.Buttons        = _ribbuttonFinder.Query(n => n
                                                          .Where(f => f.EntityId == entityid && f.StateCode == RecordState.Enabled &&
                                                                 (f.ShowArea == RibbonButtonArea.ListHead || f.ShowArea == RibbonButtonArea.ListRow)));
            return(JOk(model));
        }