示例#1
0
        public ActionResult Video_Delete(Model_Message model)
        {
            Tbl_Video _Video = db.Tbl_Video.Where(a => a.Video_ID == model.ID).SingleOrDefault();

            FileManagement fileManagement = new FileManagement();

            string path = Path.Combine(Server.MapPath("~/App_Data/"), _Video.Tbl_Document.Document_FolderName + "\\" + _Video.Tbl_Document.Document_Path);

            fileManagement.DeleteFileWithPath(path);

            db.Tbl_Document.Remove(_Video.Tbl_Document);
            db.Tbl_Video.Remove(_Video);

            if (Convert.ToBoolean(db.SaveChanges() > 0))
            {
                TempData["TosterState"]   = "success";
                TempData["TosterType"]    = TosterType.Maseage;
                TempData["TosterMassage"] = "عملیات با موفقیت انجام شد";

                return(RedirectToAction("Video_List"));
            }
            else
            {
                TempData["TosterState"]   = "error";
                TempData["TosterType"]    = TosterType.Maseage;
                TempData["TosterMassage"] = "عملیات با موفقیت انجام نشد";

                return(RedirectToAction("Video_List"));
            }
        }
示例#2
0
        public ActionResult Video_Add(Model_VideoAdd model)
        {
            if (model.Document != null && model.Document.ContentLength > 0)
            {
                Tbl_Document _Document = new Tbl_Document();
                Tbl_Video    _Video    = new Tbl_Video();
                Tbl_Login    _Login    = db.Tbl_Login.Where(a => a.Login_Email == User.Identity.Name || a.Login_Mobile == User.Identity.Name).FirstOrDefault();

                _Video.Video_Titel      = model.Tital;
                _Video.Video_Guid       = Guid.NewGuid();
                _Video.Video_IsActive   = model.IsActive;
                _Video.Video_CreateDate = DateTime.Now;
                _Video.Tbl_Login        = _Login;

                _Document.Document_FileName   = model.Document.FileName;
                _Document.Document_FolderName = "Video";
                _Document.Document_TypeCodeID = 7;
                _Document.Tbl_Login           = _Login;
                _Document.Document_CreateDate = DateTime.Now;
                _Document.Document_Guid       = Guid.NewGuid();
                _Document.Document_Path       = Guid.NewGuid().ToString();

                model.Document.SaveAs(Path.Combine(Server.MapPath("~/App_Data/Video/"), _Document.Document_Path));

                db.Tbl_Document.Add(_Document);

                _Video.Tbl_Document = _Document;

                db.Tbl_Video.Add(_Video);

                if (Convert.ToBoolean(db.SaveChanges() > 0))
                {
                    TempData["TosterState"]   = "success";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterMassage"] = "عملیات با موفقیت انجام شد";

                    return(RedirectToAction("Video_List"));
                }
                else
                {
                    TempData["TosterState"]   = "error";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterMassage"] = "عملیات با موفقیت انجام نشد";

                    return(RedirectToAction("Video_List"));
                }
            }

            return(View());
        }