internal IFacadeUpdateResult <DEntityData> SaveDEntity(DEntityDto dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <DEntityData> result = new FacadeUpdateResult <DEntityData>(); IDEntityService service = UnitOfWork.GetService <IDEntityService>(); DEntity instance = RetrieveOrNew <DEntityData, DEntity, IDEntityService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Code = dto.Code; instance.Description = dto.Description; instance.EntityTypeId = dto.EntityTypeId; instance.AllowAddItem = dto.AllowAddItem; instance.AllowDeleteItem = dto.AllowDeleteItem; instance.AllowEditItem = dto.AllowEditItem; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <DEntityData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <DEntityData> SaveDEntityItem(object parentId, DEntityItemDto childDto) { ArgumentValidator.IsNotNull("parentId", parentId); ArgumentValidator.IsNotNull("childDto", childDto); FacadeUpdateResult <DEntityData> result = new FacadeUpdateResult <DEntityData>(); IDEntityService service = UnitOfWork.GetService <IDEntityService>(); var parentQuery = service.Retrieve(parentId); if (parentQuery.HasResult) { DEntity parent = parentQuery.ToBo <DEntity>(); DEntityItem child = RetrieveOrNewDEntityItem(parent, childDto.Id); if (child != null) { child.Text = childDto.Text; child.Value = childDto.Value; var saveQuery = service.Save(parent); result.Merge(saveQuery); result.AttachResult(parent.RetrieveData <DEntityData>()); } else { AddError(result.ValidationResult, "DEntityItemCannotBeFound"); } } return(result); }