Ejemplo n.º 1
0
        public ActionResult Partner_delete(Model_Message model)
        {
            Tbl_Partner _Partner = db.Tbl_Partner.Where(a => a.Partner_ID == model.ID).SingleOrDefault();

            FileManagement fileManagement = new FileManagement();

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

            fileManagement.DeleteFileWithPath(path);

            db.Tbl_Document.Remove(_Partner.Tbl_Document);
            db.Tbl_Partner.Remove(_Partner);

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

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

                return(RedirectToAction("Partner_List"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Partner_Add(Model_PartnerAdd model)
        {
            if (model.Document != null && model.Document.ContentLength > 0)
            {
                Tbl_Document _Document = new Tbl_Document();
                Tbl_Partner  _Partner  = new Tbl_Partner();
                Tbl_Login    _Login    = db.Tbl_Login.Where(a => a.Login_Email == User.Identity.Name || a.Login_Mobile == User.Identity.Name).FirstOrDefault();

                _Partner.Partner_Titel      = model.Tital;
                _Partner.Partner_Guid       = Guid.NewGuid();
                _Partner.Partner_Link       = model.Link;
                _Partner.Partner_IsActive   = model.IsActive;
                _Partner.Partner_CreateDate = DateTime.Now;
                _Partner.Tbl_Login          = _Login;

                _Document.Document_FileName   = model.Document.FileName;
                _Document.Document_FolderName = "Partner";
                _Document.Document_TypeCodeID = 5;
                _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/Partner/"), _Document.Document_Path));

                db.Tbl_Document.Add(_Document);

                _Partner.Tbl_Document = _Document;

                db.Tbl_Partner.Add(_Partner);

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

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

                    return(RedirectToAction("Partner_List"));
                }
            }

            return(View());
        }