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 bool Import(Guid solutionId, List <Domain.QueryView> queryViews)
 {
     if (queryViews.NotEmpty())
     {
         foreach (var item in queryViews)
         {
             var entity = _queryViewFinder.FindById(item.QueryViewId);
             if (entity != null)
             {
                 entity.Description    = item.Description;
                 entity.FetchConfig    = item.FetchConfig;
                 entity.IsDefault      = item.IsDefault;
                 entity.StateCode      = item.StateCode;
                 entity.LayoutConfig   = item.LayoutConfig;
                 entity.IsCustomButton = item.IsCustomButton;
                 entity.CustomButtons  = item.CustomButtons;
                 entity.TargetFormId   = item.TargetFormId;
                 entity.ModifiedBy     = _appContext.GetFeature <ICurrentUser>().SystemUserId;
                 entity.ModifiedOn     = DateTime.Now;
                 entity.Name           = item.Name;
                 _queryViewUpdater.Update(entity);
             }
             else
             {
                 item.SolutionId     = solutionId;
                 item.ComponentState = 0;
                 item.CreatedBy      = _appContext.GetFeature <ICurrentUser>().SystemUserId;
                 item.CreatedOn      = DateTime.Now;
                 _queryViewCreater.Create(item);
             }
         }
     }
     return(true);
 }