public string Add(YoutubeVideo sample)
        {
            string status;

            try
            {
                YoutubeVideo videoSample           = new YoutubeVideo();
                YouTubeDemoModuleDbContext context = new YouTubeDemoModuleDbContext();
                videoSample.CreatedBy    = sample.CreatedBy;
                videoSample.CreatedDate  = sample.CreatedDate;
                videoSample.Id           = sample.Id;
                videoSample.ModifiedBy   = sample.ModifiedBy;
                videoSample.ModifiedDate = sample.ModifiedDate;
                videoSample.ProductId    = sample.ProductId;
                videoSample.VideoTitle   = sample.VideoTitle;
                videoSample.YoutubeId    = sample.YoutubeId;



                context.YouTubeDemo.Add(videoSample);
                context.SaveChanges();
                status = "Success";
            }
            catch (Exception ex)
            {
                status = ex.InnerException.Message;
            }
            return(status);
        }
Exemple #2
0
        public string Delete(string id)
        {
            try
            {
                var item = _repository.YoutubeVideos.Where(q => q.ProductId == id).FirstOrDefault();
                if (item != null)
                {
                    YouTubeDemoModuleDbContext context = new YouTubeDemoModuleDbContext();
                    context.Videos.Remove(item);
                    context.SaveChanges();
                    return("Success");
                }


                return("Failed");
            }
            catch (System.Exception e)
            {
                return(e.Message);
            }
        }