Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "ma,ten")] DanhMuc danhMuc)
        {
            if (ModelState.IsValid)
            {
                db.DanhMucs.Add(danhMuc);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(danhMuc));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "ma,so_phong,ma_khu_tro,nguoi_thue,cmtnd")] PhongTro phongTro)
        {
            if (ModelState.IsValid)
            {
                db.PhongTroes.Add(phongTro);
                db.SaveChanges();
                return(Redirect("/Admin/Rooms/Index?groupId=" + phongTro.ma_khu_tro));
            }

            ViewBag.ma_khu_tro = new SelectList(db.KhuTroes, "ma", "dia_chi", phongTro.ma_khu_tro);
            return(View(phongTro));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "ma,da_xoa,dia_chi,chu_tro")] KhuTro khuTro)
        {
            if (ModelState.IsValid)
            {
                TaiKhoan loginAccount = Session["LoginAccount"] as TaiKhoan;
                khuTro.chu_tro = loginAccount.tai_khoan;
                db.KhuTroes.Add(khuTro);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.chu_tro = new SelectList(db.TaiKhoans, "tai_khoan", "mat_khau", khuTro.chu_tro);
            return(View(khuTro));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "tai_khoan,mat_khau,ten_hien_thi,hinh_anh,loai_tai_khoan,ten,ngay_sinh,so_dien_thoai,email")] TaiKhoan taiKhoan)
        {
            if (ModelState.IsValid)
            {
                db.TaiKhoans.Add(taiKhoan);

                if (Request.Files.Count > 0 && Request.Files[0].FileName.Trim() != "")
                {
                    string[] _arr = Request.Files[0].FileName.Split('.');
                    string   type = _arr[_arr.Length - 1];

                    taiKhoan.hinh_anh = taiKhoan.tai_khoan + "." + type;
                    Request.Files[0].SaveAs(Server.MapPath("~/Public/upload/account/") + taiKhoan.hinh_anh);
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(taiKhoan));
        }
Ejemplo n.º 5
0
        public ActionResult ChangeProfile(TaiKhoan taiKhoan)
        {
            TaiKhoan loginAccount = (TaiKhoan)Session["LoginAccount"];

            TaiKhoan _account = db.TaiKhoans.Find(loginAccount.tai_khoan);

            _account.ten           = taiKhoan.ten;
            _account.ten_hien_thi  = taiKhoan.ten_hien_thi;
            _account.so_dien_thoai = taiKhoan.so_dien_thoai;

            if (Request.Files.Count > 0 && Request.Files[0].FileName.Trim() != "")
            {
                string[] _arr = Request.Files[0].FileName.Split('.');
                string   type = _arr[_arr.Length - 1];

                taiKhoan.hinh_anh = taiKhoan.tai_khoan + "." + type;
                Request.Files[0].SaveAs(Server.MapPath("~/Public/upload/account/") + taiKhoan.hinh_anh);
            }

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 6
0
        public ActionResult Create([Bind(Include = "ma,tieu_de,hinh_anh,noi_dung,ngay_tao,nguoi_tao,dia_chi,dien_tich,gia_ca,do_uu_tien,ma_danh_muc")] BaiViet baiViet)
        {
            if (ModelState.IsValid)
            {
                baiViet.noi_dung = HttpUtility.HtmlDecode(baiViet.noi_dung.Replace(System.Environment.NewLine, ""));
                baiViet.ngay_tao = DateTime.Now;
                baiViet          = db.BaiViets.Add(baiViet);
                db.SaveChanges();

                if (Request.Files.Count > 0 && Request.Files[0].FileName.Trim() != "")
                {
                    string[] _arr = Request.Files[0].FileName.Split('.');
                    string   type = _arr[_arr.Length - 1];

                    baiViet.hinh_anh = baiViet.ma + "." + type;
                    Request.Files[0].SaveAs(Server.MapPath("~/Public/upload/post/") + baiViet.hinh_anh);
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ma_danh_muc = new SelectList(db.DanhMucs, "ma", "ten", baiViet.ma_danh_muc);
            return(View(baiViet));
        }