public PageCustomizationDTO GetCustomizationData(long id) { var p = Unit.PageRepository.FindSingleAs(d => new { d.ViewPath, d.Name, d.TenantId, d.Tenant.Code, d.Layout }, id); if (p == null) { return(null); } var dto = new PageCustomizationDTO { Controls = Unit.PageControlRepository.FindAs(PageControlListDTO.Expression, d => d.PageId == id), Parameters = Unit.PageParameterRepository.FindForPage(id), Route = Unit.PageRouteRepository.FindByPage(id) ?? new PageRouteDTO(), Fields = Unit.CustomFieldRepository.Find(d => d.PageId == id), ViewPath = p.ViewPath, Id = id, TenantId = p.TenantId, TenantCode = p.Code, Layout = p.Layout }; return(dto); }
public IActionResult ApplyCustomization([FromBody] PageCustomizationDTO dto) { SubmitResult = _service.ApplyCustomization(dto); return(Respond()); }
public SubmitResult ApplyCustomization(PageCustomizationDTO dto) { if (dto.Controls != null && dto.Controls.Any()) { var list = dto.Controls.MapTo <PageControl>(false); Unit.PageControlRepository.ApplyChanges(list); } if (dto.Parameters != null && dto.Parameters.Any()) { foreach (var par in dto.Parameters) { if (par.Entity.Id == 0) { par.Entity.State = "Added"; par.Entity.PageId = dto.Id; par.Entity.PageCategoryParameterId = par.Id; } else { par.Entity.State = par.State; } } Unit.PageParameterRepository.ApplyChanges(dto.Parameters.Select(d => d.Entity)); } if (dto.Route != null) { var rout = Unit.PageRouteRepository.FindSingle(dto.Route.Id); if (rout == null) { rout = new PageRoute { PageId = dto.Id, }; Unit.PageRouteRepository.Add(rout); } else { Unit.PageRouteRepository.Update(rout); } rout.AppendProperties(dto.Route, true, new[] { "CreatedOn", "CreatedBy", "PageId" }); } Unit.CustomFieldRepository.ApplyChanges(dto.Fields); var res = Unit.SaveChanges(); if (res.Code == 0) { var pars = Unit.PageParameterRepository.FindForJsonByPage(dto.Id); var page = Unit.PageRepository.FindSingle(dto.Id); if (page.Layout != dto.Layout) { page.Layout = dto.Layout; Unit.PageRepository.Update(page); } if (dto.Route == null) { dto.Route = Unit.PageRouteRepository.FindByPage(dto.Id); } var fs = Unit.CustomFieldRepository.FindAs(FieldDefinition.Expression, d => d.PageId == dto.Id).ToArray(); fs = fs.Any() ? fs : null; Unit.PageRepository.UpdatePageViewParamsJson(page, pars.ToArray(), dto.Route, fs); res.Data["updatingJsonResult"] = Unit.SaveChanges(); } return(res); }
public IActionResult GetCustomizationData(long id) { PageCustomizationDTO data = _service.GetCustomizationData(id); return(Respond(data)); }