예제 #1
0
        public ActionResult ThongTinThemCapNhat(string Id)
        {
            var duLieuOutput = new CommonQuangCao.QuangCaoOutput.ThongTinQuangCao();

            ViewBag.DanhSachDonVi = DocDanhSachDonVi();
            var danhSachNenTang = StaticList.NenTangs();

            ViewBag.DanhSachNenTang = danhSachNenTang;
            try
            {
                if (!string.IsNullOrEmpty(Id))
                {
                    var input = new CommonInput.DocThongTinInput {
                        Id = Id
                    };
                    var output = XuLyAPI.ApiJsonPost(APIUrl.QuangCao.DocThongTin, input) as CommonOutput;
                    if (output == null)
                    {
                        throw new Exception(ConstantValues.Message.LoiServer);
                    }
                    if (output.KetQua != 1)
                    {
                        throw new Exception(output.ThongBao);
                    }
                    duLieuOutput = JsonConvert.DeserializeObject <CommonQuangCao.QuangCaoOutput.ThongTinQuangCao>(output.DuLieu.ToString());
                    if (!string.IsNullOrEmpty(duLieuOutput.MaNenTang))
                    {
                        ViewBag.DanhSachLoai = DocDanhSachLoai(duLieuOutput.MaNenTang);
                    }
                }
            }
            catch (Exception)
            {
            }
            return(PartialView("_ThemCapNhatPartial", duLieuOutput));
        }
예제 #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));
            }
        }