public IHttpActionResult Get()
 {
     try
     {
         using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
         {
             var seriesList = dbcontext.Series.Select(s => new
             {
                 s.id,
                 s.name,
                 s.categories,
                 s.language,
                 s.story,
                 s.forkid,
                 s.videourl,
                 s.imageurl,
                 count = dbcontext.Episodes.Where(e => e.seriesid == s.id).ToList().Count()
             }).ToList();
             return(Ok(seriesList));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest("Error : " + ex));
     }
 }
 public IHttpActionResult CheckLogin(User user)
 {
     try
     {
         using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
         {
             User existing = dbcontext.Users.FirstOrDefault(u => u.name == user.name);
             if (existing == null)
             {
                 return(BadRequest("Coundn't find your Movify Account"));
             }
             else
             {
                 if (existing.password == user.password)
                 {
                     existing.password = null;
                     return(Ok(existing));
                 }
                 else
                 {
                     return(BadRequest("Wrong password. Try again or click Forgot password to reset it."));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         return(BadRequest("Error : " + ex));
     }
 }
        public IHttpActionResult Post(User user)
        {
            try
            {
                using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
                {
                    User existing = dbcontext.Users.FirstOrDefault(u => u.name == user.name);
                    if (existing != null)
                    {
                        return(BadRequest("Username exist, please select another username."));
                    }
                    existing = dbcontext.Users.FirstOrDefault(u => u.emailid == user.emailid);
                    if (existing != null)
                    {
                        return(BadRequest("Emailid exist, please select another emailid."));
                    }

                    dbcontext.Users.Add(user);
                    dbcontext.SaveChanges();
                    return(Ok(user));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest("Error : " + ex));
            }
        }
        public IHttpActionResult Post()
        {
            var request = HttpContext.Current.Request;

            try
            {
                if (request.Files.Count == 2)
                {
                    //imagefile
                    var imageurl     = request.Files["imageurl"];
                    var uploadFolder = HttpContext.Current.Server.MapPath("~/uploads");

                    String uniqueImageFileName = (Guid.NewGuid().ToString() + imageurl.FileName);
                    String imagefilePath       = uploadFolder + "/" + uniqueImageFileName;
                    imageurl.SaveAs(imagefilePath);

                    //video file
                    var videourl = request.Files["videourl"];

                    String uniquevideoFileName = (Guid.NewGuid().ToString() + videourl.FileName);
                    String videofilePath       = uploadFolder + "/" + uniquevideoFileName;
                    videourl.SaveAs(videofilePath);

                    using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
                    {
                        Movie movie = new Movie();
                        movie.name       = request["name"];
                        movie.language   = request["language"];
                        movie.categories = request["categories"];
                        //movie.duration = request["duration"];
                        movie.releaseddate = request["releaseddate"];
                        movie.story        = request["story"];
                        movie.forkid       = request["forkid"] == "1";
                        movie.views        = 0;
                        movie.imageurl     = "/uploads/" + uniqueImageFileName;
                        movie.videourl     = "/uploads/" + uniquevideoFileName;

                        dbcontext.Movies.Add(movie);
                        dbcontext.SaveChanges();
                        return(Ok(movie));
                    }
                }
                else
                {
                    return(BadRequest("Please upload both image and video files"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest("Error : " + ex));
            }
        }
Example #5
0
        public IHttpActionResult Post()
        {
            var request = HttpContext.Current.Request;

            try
            {
                if (request.Files.Count == 2)
                {
                    //imagefile
                    var imageurl     = request.Files["imageurl"];
                    var uploadFolder = HttpContext.Current.Server.MapPath("~/uploads");

                    String uniqueImageFileName = (Guid.NewGuid().ToString() + imageurl.FileName);
                    String imagefilePath       = uploadFolder + "/" + uniqueImageFileName;
                    imageurl.SaveAs(imagefilePath);

                    //video file
                    var videourl = request.Files["videourl"];

                    String uniquevideoFileName = (Guid.NewGuid().ToString() + videourl.FileName);
                    String videofilePath       = uploadFolder + "/" + uniquevideoFileName;
                    videourl.SaveAs(videofilePath);

                    using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
                    {
                        Episode episode = new Episode();
                        episode.name     = request["name"];
                        episode.seriesid = Convert.ToInt32(request["seriesid"]);
                        episode.date     = System.DateTime.Now.ToShortDateString();
                        episode.views    = 0;
                        episode.likes    = 0;
                        episode.dislikes = 0;
                        episode.imageurl = "/uploads/" + uniqueImageFileName;
                        episode.videourl = "/uploads/" + uniquevideoFileName;

                        dbcontext.Episodes.Add(episode);
                        dbcontext.SaveChanges();
                        return(Ok(episode));
                    }
                }
                else
                {
                    return(BadRequest("Please upload both image and video files"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest("Error : " + ex));
            }
        }
Example #6
0
 public IHttpActionResult Get(int id)
 {
     try
     {
         using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
         {
             return(Ok(dbcontext.Episodes.FirstOrDefault(e => e.id == id)));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest("Error : " + ex));
     }
 }
Example #7
0
 public IHttpActionResult GetEpisodesCountForSeriesId(int seriesid)
 {
     try
     {
         using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
         {
             return(Ok(dbcontext.Episodes.Where(e => e.seriesid == seriesid).ToList().Count()));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest("Error : " + ex));
     }
 }
 public IHttpActionResult Get()
 {
     try
     {
         using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
         {
             return(Ok(dbcontext.Categories.ToList()));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest("Error : " + ex));
     }
 }
 public IHttpActionResult Post(Category category)
 {
     try
     {
         using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
         {
             dbcontext.Categories.Add(category);
             dbcontext.SaveChanges();
             return(Ok(category));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest("Error : " + ex));
     }
 }
Example #10
0
 public IHttpActionResult Post(Language language)
 {
     try
     {
         using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
         {
             dbcontext.Languages.Add(language);
             dbcontext.SaveChanges();
             return(Ok(language));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest("Error : " + ex));
     }
 }
Example #11
0
 public IHttpActionResult IncrViews(int id)
 {
     try
     {
         using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
         {
             Episode existing = dbcontext.Episodes.FirstOrDefault(e => e.id == id);
             if (existing == null)
             {
                 return(NotFound());
             }
             else
             {
                 existing.views = existing.views + 1;
                 dbcontext.SaveChanges();
                 return(Ok(existing.views));
             }
         }
     }
     catch (Exception ex)
     {
         return(BadRequest("Error : " + ex));
     }
 }
 public IHttpActionResult Delete(int id)
 {
     try
     {
         using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
         {
             Category existing = dbcontext.Categories.FirstOrDefault(c => c.id == id);
             if (existing == null)
             {
                 return(NotFound());
             }
             else
             {
                 dbcontext.Categories.Remove(existing);
                 dbcontext.SaveChanges();
                 return(Ok(existing));
             }
         }
     }
     catch (Exception ex)
     {
         return(BadRequest("Error : " + ex));
     }
 }
Example #13
0
 public IHttpActionResult Put(int id, Language language)
 {
     try
     {
         using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
         {
             Language existing = dbcontext.Languages.FirstOrDefault(l => l.id == id);
             if (existing == null)
             {
                 return(NotFound());
             }
             else
             {
                 existing.name = language.name;
                 dbcontext.SaveChanges();
                 return(Ok(existing));
             }
         }
     }
     catch (Exception ex)
     {
         return(BadRequest("Error : " + ex));
     }
 }
 public IHttpActionResult ForgetPassword(User user)
 {
     try
     {
         using (WebSeriesDBEntities dbcontext = new WebSeriesDBEntities())
         {
             User existing = dbcontext.Users.FirstOrDefault(u => u.emailid == user.emailid);
             if (existing == null)
             {
                 return(BadRequest("Emailid does not exist"));
             }
             else
             {
                 string body = "Username = "******" Password = "******"Password Recovery", body, user.emailid);
                 return(Ok("Login details are sent to registered emailid"));
             }
         }
     }
     catch (Exception ex)
     {
         return(BadRequest("Error : " + ex));
     }
 }