Exemplo n.º 1
0
        public ActionResult XuLyLuu(CommonChucVu.ChucVuInput.ThongTinChucVu input)
        {
            var model  = new CommonOutput();
            var input2 = new CommonChucVu.ChucVuOutput.ThongTinChucVu();

            ViewBag.DanhSachViTri      = StaticList.ViTriChucVus();
            ViewBag.DanhSachThuocTrang = StaticList.ThuocTrangs();
            try
            {
                input2.Id       = input.Id;
                input2.Ten      = input.Ten;
                input2.MoTa     = input.MoTa;
                input2.ThuTu    = input.ThuTu;
                input2.KichHoat = input.KichHoat;
                input2.Ma       = input.Ma;
                var url    = !string.IsNullOrEmpty(input.Id) ? APIUrl.ChucVu.Sua : APIUrl.ChucVu.Them;
                var output = XuLyAPI.ApiJsonPost(url, input) as CommonOutput;
                if (output == null)
                {
                    throw new Exception(ConstantValues.Message.LoiServer);
                }
                if (output.KetQua == 1)
                {
                    model.KetQua   = 1;
                    model.ThongBao = ConstantValues.Message.ThanhCong;
                    ViewBag.KetQua = 1;
                    return(PartialView("_ThemCapNhatPartial", new CommonChucVu.ChucVuOutput.ThongTinChucVu()));
                }
                else
                {
                    return(PartialView("_ThemCapNhatPartial", input2));
                }
            }
            catch (Exception ex)
            {
                model.KetQua   = 0;
                model.ThongBao = ConstantValues.Message.ThatBai;
                return(PartialView("_ThemCapNhatPartial", input2));
            }
        }
Exemplo n.º 2
0
        public ActionResult XuLyLuu(CommonQuangCao.QuangCaoInput.ThongTinQuangCao input)
        {
            TempData["returnUrl"] = Url.Action("Index", "QuangCao", new { Areas = "QuangCao" });
            var kiemTra = XuLyPhanQuyen.KiemTraQuyenTruyCap(ChucNang.Ma.QuangCao, QuyenHan.Ma.Them);

            ViewBag.KetQua = kiemTra.KetQua;
            if (kiemTra.KetQua < 0)
            {
                return(PartialView("_ThemCapNhatPartial", new CommonQuangCao.QuangCaoOutput.ThongTinQuangCao()));
            }

            var model  = new CommonOutput();
            var input2 = new CommonQuangCao.QuangCaoOutput.ThongTinQuangCao();

            ViewBag.DanhSachViTri = StaticList.ViTriQuangCaos();
            var danhSachNenTang = StaticList.NenTangs();

            ViewBag.DanhSachNenTang    = danhSachNenTang;
            ViewBag.DanhSachThuocTrang = StaticList.ThuocTrangs().Where(n => n.MaNenTang == danhSachNenTang.FirstOrDefault().Value.ToString()).ToList();
            try
            {
                input2.Id           = input.Id;
                input2.IdDonVi      = input.IdDonVi;
                input2.MaNenTang    = input.MaNenTang;
                input2.MaLoai       = input.MaLoai;
                input2.TieuDe       = input.TieuDe;
                input2.MoTa         = input.MoTa;
                input2.NoiDung      = input.NoiDung;
                input2.ThuTuHienThi = input.ThuTuHienThi;
                input2.KichHoat     = input.KichHoat;
                input2.UuTien       = input.UuTien;
                input2.HinhDaiDien  = input.HinhDaiDien;
                input2.DuongDan     = input.DuongDan;
                input2.ChuoiTuNgay  = input.TuNgay;
                input2.ChuoiDenNgay = input.DenNgay;
                //input2.SoLuotClick = input.SoLuotClick;
                //input2.SoLuotHienThi = input.SoLuotHienThi;

                var url    = !string.IsNullOrEmpty(input.Id) ? APIUrl.QuangCao.Sua : APIUrl.QuangCao.Them;
                var output = XuLyAPI.ApiJsonPost(url, input) as CommonOutput;
                if (output == null)
                {
                    throw new Exception(ConstantValues.Message.LoiServer);
                }
                if (output.KetQua == 1)
                {
                    model.KetQua   = 1;
                    model.ThongBao = ConstantValues.Message.ThanhCong;
                    ViewBag.KetQua = 1;
                    return(PartialView("_ThemCapNhatPartial", new CommonQuangCao.QuangCaoOutput.ThongTinQuangCao()));
                }
                else
                {
                    ViewBag.KetQua = 0;
                    return(PartialView("_ThemCapNhatPartial", input2));
                }
            }
            catch (Exception)
            {
                ViewBag.KetQua = 0;
                model.KetQua   = 0;
                model.ThongBao = ConstantValues.Message.ThatBai;
                return(PartialView("_ThemCapNhatPartial", input2));
            }
        }