public ActionResult EditVideo(AddPictureVideoViewModel apvm)
 {
     if (Session["UserId"] != null)
     {
         if (Session["dispensaryId"] != null)
         {
             int dispenId = int.Parse(Session["dispensaryId"].ToString());
             int userid = int.Parse(Session["UserId"].ToString());
             string str = apvm.VideoSource.Substring(31).ToString();
             apvm.VideoImageSrc = "http://i1.ytimg.com/vi/" + str + "/hqdefault.jpg";
             _dbds.UpdateVideo(disMaps.VideoViewModelToVideo(apvm));
             return RedirectToAction("Videos", "Properties");
         }
         else
         {
             return RedirectToAction("AddDispensaries", "Properties");
         }
     }
     else
     {
         return RedirectToAction("LogIn", "Home");
     }
 }
        public ActionResult AddNewPictures(AddPictureVideoViewModel apvm, HttpPostedFileBase picture)
        {
            if (Session["UserId"] != null)
            {
                if (Session["dispensaryId"] != null)
                {

                    int dispenaryid = int.Parse(Session["dispensaryId"].ToString());
                    int userid = int.Parse(Session["UserId"].ToString());
                    if (picture != null && picture.ContentLength > 0)
                    {
                        string ext = picture.FileName;
                        ext = ext.Substring(ext.LastIndexOf("."));
                        if (ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".JPG" || ext == ".JPEG" || ext == ".PNG")
                        {
                            var fileName = Path.GetFileName(picture.FileName);
                            string originalpath = picture.FileName;
                            fileName = fileName.Substring(0, fileName.LastIndexOf(".") - 1);
                            fileName = fileName + DateTime.Now.Ticks.ToString() + ext;
                            var path = Path.Combine(Server.MapPath("~/Pictures/"), fileName);
                            picture.SaveAs(path);
                            string path1 = "~/Pictures/" + fileName;
                            apvm.PictureName = picture.FileName;
                            apvm.PictureSource = path1;
                        }
                        else
                        {
                            ViewBag.Message = "Invalid Image.";
                            return View();
                        }
                    }

                    _dbds.InsertPicture(dispenaryid, disMaps.PictureViewModelTopicture(apvm));
                    return RedirectToAction("Pictures", "Properties");
                }
                else
                {
                    return RedirectToAction("AddDispensaries", "Properties");
                }
            }
            else
            {
                return RedirectToAction("LogIn", "Home");
            }
        }