예제 #1
0
        public static Video SaveNewVideo(bool IsCoverVideo,int UserID,string UserEmail="")
        {
            try
            {


                Video NewVideo = new Video();

                using (var context = new PostContext())
                {
                    // save New Video block .......
                    NewVideo.CreatedOnDate = DateTime.Now;
                    NewVideo.IsCoverVideo = IsCoverVideo;
                    NewVideo.ModifiedOnDate = null;
                    NewVideo.VideoID = CreateNewID();
                    NewVideo.UserEmail = UserEmail;
                    NewVideo.VideoPath = UploadVideo(NewVideo);
                    NewVideo.UserID = UserID;
                    context.Videos.Add(NewVideo);
                    context.SaveChanges();
                }
                return NewVideo;

            }
            catch(Exception ex)
            {
                throw ex;
            }
            }
예제 #2
0
        public static CoverPhoto SaveNewPhoto(int UserID,string UserEmail)
        {
            try
            {


                CoverPhoto NewPhoto = new CoverPhoto();

                using (var context = new PostContext())
                {
                    // save New Video block .......

                    NewPhoto.UserID = UserID;
                    NewPhoto.UserEmail = UserEmail;
                    NewPhoto.PhotoPath = UploadPhoto(NewPhoto);
                    context.Photos.Add(NewPhoto);
                    context.SaveChanges();
                }
                return NewPhoto;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public static string SaveNewPost(AddPostDTO PostDTO)
        {
            Post NewPost = new Post();
            //// save New Video block .......

            NewPost.VideoID = SaveNewVideo(false, PostDTO.UserID).VideoID;
            using (var context=new PostContext())
            {
                
                /// save new Post block ..............
                NewPost.PostID = CreateNewID();
                 NewPost.IsActive = true;
                NewPost.Description = PostDTO.Description;
                NewPost.CountryID = PostDTO.CountryID;
                NewPost.RoundID = PostDTO.RoundID;
                NewPost.Titel = PostDTO.Titel;
                NewPost.Place = PostDTO.Place; 
                context.Posts.Add(NewPost);

                // save changes to the DB ...........
                context.SaveChanges();
            }
            return "";
        }