示例#1
0
        public async Task CreateTest()
        {
            var dto = new CreateNotesDTO
            {
                CatalogName = "/小学/语文/人教版/一年级上",
                CatalogCode = "/1/1/2/1",
                Content     = "",
                Section     = new NotesComponent
                {
                    Id    = Guid.Parse("809953A6-EFF7-45E1-BAC7-477D2D0332A9"),
                    Value = "我是一个任务"
                },
                Page = new NotesComponent
                {
                    Id    = Guid.Parse("13CF28FC-25DA-4B86-96E7-FD61DA29734C"),
                    Value = "我是一个分页"
                },
            };

            var c = ContainerHelper.Builder();

            var noteSvc = c.Resolve <INotesSvc>();

            var nc = this.NC(); //new NotesController(noteSvc ,c.Resolve<IBodySvc>()
                                //           ,c.Resolve<IEntry>()
                                //          ,c.Resolve<);


            var id = await nc.CreateNotes(dto);

            Assert.IsNotNull(id);
        }
示例#2
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <returns></returns>
        public async Task <NotesObj> CreateAsync(CreateNotesDTO dto, Guid notesId, string userName, string userId)
        {
            var notes = new NotesObj();

            notes.Create(dto, notesId, userId, userName);

            //using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

            //try
            //{

            await this._envSender.SendAsync(new NotesCreated
            {
                Notes    = notes.Notes,
                Sections = notes.CurrentSection?.Sections,
                Page     = notes.CurrentSection?.CurrentPage?.Page
            });

            await this._loader.Save(notes);

            //scope.Complete();

            //}
            //catch (Exception)
            //{
            //    throw;
            //}

            return(notes);
        }
示例#3
0
        internal void Create(CreateNotesDTO dto, Guid notesId, string userId, string userName)
        {
            this.Notes = new NotesEntity
            {
                Id          = notesId,
                Name        = dto.Name,
                CreatorId   = userId,   //user.UserId,
                CreatorName = userName, // user.UserName,
                CalelogCode = dto.CatalogCode,
                Catelog     = dto.CatalogName,
                ClassId     = dto.ClassId,
                Grade       = dto.GradeName,
                GradeCode   = dto.GradeCode,
                Source      = dto.Source
            };

            //if (String.IsNullOrEmpty(this.Notes.Name))
            //{
            //    this.Notes.Name = dto.CatalogName.Replace('/', '-');
            //}


            var sc = dto.Section == null ? null : new SectionValue(this.Notes.Id, dto.Section.Id, dto.Section.Value);

            if (sc == null)
            {
                return;
            }

            this.CurrentSection = sc;


            var pv = (dto.Page == null || dto.Page.Id == Guid.Empty) ? null : new PageValue(new NotesPageEntity
            {
                NotesId   = this.Notes.Id,
                SectionId = sc.Sections.Id,//dto.Section.Id,
                Id        = dto.Page.Id,
                Name      = dto.Page.Value
            });


            sc.AddPages(pv);

            this.AddSection(sc);
        }
示例#4
0
        public async Task <Guid> CreateNotes(string name)
        {
            var dto = new CreateNotesDTO
            {
                CatalogName = "/小学/语文/人教版/一年级上",
                CatalogCode = "/1/1/2/1",
                Name        = name
            };

            var c = ContainerHelper.Builder();

            var noteSvc = c.Resolve <INotesSvc>();

            var nc = this.NC(); //new NotesController(noteSvc);


            var id = await nc.CreateNotes(dto);

            return(id.Data);
        }
示例#5
0
        public async Task <ApiResponseAsync <Guid> > CreateNotes(CreateNotesDTO dto)
        {
            if (dto.Section != null)
            {
                dto.Section.Id = Guid.NewGuid();
            }

            if (dto.Page != null)
            {
                dto.Page.Id = Guid.NewGuid();
            }

            if (String.IsNullOrEmpty(dto.ClassId))
            {
                //dto.ClassId = await this._appUser.ClassIdAsync();
            }

            var ret = await this._notes.CreateAsync(dto, Guid.NewGuid(), this._appUser.UserName, this._appUser.UserId);

            await this._userRoot.ReferenceCatalog(this._appUser.UserId, dto.CatalogCode, dto.CatalogName, dto.GradeCode, dto.GradeName);


            return(ApiRes.OK(ret.Notes.Id));
        }