コード例 #1
0
ファイル: Program.cs プロジェクト: Sathyaish/NOWReport
        private static void RunOld(string[] args)
        {
            try
            {
                if (args.IsNull() || args.ThereAreNot(3))
                {
                    PrintUsageOld();

                    goto AwaitTerminationKeyChar;
                }

                var destinationFormat = args[0];
                var csvFile           = new FileInfo(args[1]).FullName;
                var destinationFile   = new FileInfo(args[2]).FullName;

                var lesson = VideoLesson.FromCSV(csvFile);

                if (destinationFormat == "pdf")
                {
                    lesson.ToPDF(destinationFile);
                }
                else
                {
                    lesson.ToFlatFile(destinationFile);
                }

                Console.WriteLine("Your file is saved at {0}", destinationFile);
            }
            catch (Exception exception)
            {
                Console.WriteLine("An error occurred:\n{0}", exception.Message);
            }

AwaitTerminationKeyChar:
#if DEBUG
            Console.Write("\nPress any key to exit the program...");
            Console.ReadKey();
#endif
        }
コード例 #2
0
        public async Task <VideoLessonViewModel> Details(int videoId)
        {
            var commentsFromDb = this.db.VideoLessonComments.Where(x => x.VideoLessonId == videoId).Include(x => x.Author).ToHashSet();

            VideoLesson videoLesson = await this.db.VideoLessons
                                      .Where(DbVideo => DbVideo.Id == videoId)
                                      .Include(DbVideo => DbVideo.Author)
                                      .Include(DbVideo => DbVideo.Disciplines)
                                      .SingleOrDefaultAsync();

            var comments = new HashSet <CommentViewModel>();

            foreach (var comm in commentsFromDb)
            {
                CommentViewModel commView = new CommentViewModel
                {
                    Author        = comm.Author,
                    Text          = comm.Text,
                    VideoLessonId = comm.VideoLessonId
                };
                comments.Add(commView);
            }

            VideoLessonViewModel video = new VideoLessonViewModel
            {
                Author      = videoLesson.Author,
                Description = videoLesson.Description,
                Disciplines = videoLesson.Disciplines,
                ForTeachers = videoLesson.ForTeachers,
                Id          = videoLesson.Id,
                Name        = videoLesson.Name,
                Url         = videoLesson.Url,
                Comments    = comments
            };


            return(video);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            //register services
            CoreLogic.RegisterationOfModelServicesPair(new Book(), new List <Type>()
            {
                new BookService().GetType(), new DeliveryService().GetType(), new GenerateCommissionPaymentService().GetType()
            });
            CoreLogic.RegisterationOfModelServicesPair(new VideoLesson(), new List <Type> {
                new VideoLessonService().GetType()
            });
            CoreLogic.RegisterationOfModelServicesPair(new Person(), new List <Type> {
                new MembershipService().GetType(), new SendEmailService().GetType()
            });

            //create models and request
            Book book = new Book()
            {
                Author = "Tolkien", Name = "Hobbit", Address = "street", Id = 8, ImportantNumber = 234, Sum = (float)4.6
            };

            CoreLogic.NewRequest(book);

            VideoLesson lesson = new VideoLesson()
            {
                Author = "Smith", Name = "John", Id = 123
            };

            CoreLogic.NewRequest(lesson);

            Person person = new Person()
            {
                Name = "Jon", MembershipAction = MembershipAction.MakeNew, DayOfstart = DateTime.Now, Email = "*****@*****.**"
            };

            CoreLogic.NewRequest(person);
        }
コード例 #4
0
        public async Task <string> Create(VideoLessonInputModel model)
        {
            //TODO: Validate model
            VideoLesson video  = Mapper.Map <VideoLesson>(model);
            var         userId = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            video.AuthorId = userId;

            if (model.DisciplineName != null && model.Grade != null)
            {
                var disc = await disciplineService.CreateDiscipline(model.DisciplineName, model.Grade);

                video.Disciplines.Add(disc);
            }

            #region Old Manual Mapping
            //VideoLesson video = new VideoLesson()
            //{
            //    AuthorId = userId,
            //    Description = model.Description,
            //    Disciplines = model.Disciplines,
            //    ForTeachers = model.ForTeachers,
            //    Name = model.Name,
            //    Url = model.Url,
            //    Rating = 0,
            //    VideoLessonComments = new HashSet<VideoLessonComment>()

            //};
            #endregion

            db.VideoLessons.Add(video);
            await db.SaveChangesAsync();

            var result = $"You have successfully added the video {model.Name}!";
            return(result);
        }
コード例 #5
0
 public async Task AddDisciplineTo(Discipline dicipline, VideoLesson videoLesson)
 {
     videoLesson.Disciplines.Add(dicipline);
     await db.SaveChangesAsync();
 }