Пример #1
0
        public ActionResult ThongTinThemCapNhatNhomTin(string Id)
        {
            var duLieuOutput     = new Models.NhomTinModel.NhomTinOutput.ThongTin();
            var DanhSachPhongBan = DocDanhSachDonVi();

            ViewBag.IdPhongBan = new SelectList(DanhSachPhongBan, "Value", "Text", "Ma");
            try
            {
                if (!string.IsNullOrEmpty(Id))
                {
                    var input = new CommonInput.DocThongTinInput {
                        Id = Id
                    };
                    var output = XuLyAPI.ApiJsonPost2(APIUrl.LoaiBaoCao.DocThongTin, input, false) as CommonOutput;
                    if (output == null)
                    {
                        throw new Exception(Message.LoiServer);
                    }
                    if (output.KetQua != 1)
                    {
                        throw new Exception(output.ThongBao);
                    }
                    duLieuOutput = JsonConvert.DeserializeObject <Models.NhomTinModel.NhomTinOutput.ThongTin>(output.DuLieu.ToString());
                }
            }
            catch (Exception)
            {
            }
            return(PartialView("_ThemCapNhatNhomTinPartial", duLieuOutput));
        }
Пример #2
0
        public ActionResult XuLyLuuNhomTin(CommonNhomTin.NhomTinInput.ThongTinNhomTin input)
        {
            TempData["returnUrl"] = Url.Action("NhomTin", "TinTuc", new { Areas = "TinTuc" });
            //var kiemTra = XuLyPhanQuyen.KiemTraQuyenTruyCap(ChucNang.Ma.NhomTin, QuyenHan.Ma.Them);
            //ViewBag.KetQua = kiemTra.KetQua;
            //if (kiemTra.KetQua < 0) return PartialView("_ThemCapNhatPartial", new CommonNhomTin.NhomTinOutput.ThongTin());

            var model            = new CommonOutput();
            var input2           = new Models.NhomTinModel.NhomTinOutput.ThongTin();
            var DanhSachPhongBan = DocDanhSachDonVi();

            ViewBag.IdPhongBan = new SelectList(DanhSachPhongBan, "Value", "Text", "Ma");
            try
            {
                input2.Id       = input.Id;
                input2.Ten      = input.Ten;
                input2.DuongDan = input.DuongDan;
                input2.ThuTu    = input.ThuTu;
                input2.MoTa     = input.MoTa;
                input2.KichHoat = input.KichHoat;
                var ids = new List <string>();
                if (input.DanhSachIdPhongBan != null)
                {
                    foreach (var id in input.DanhSachIdPhongBan)
                    {
                        ids.Add(id);
                    }
                }

                input2.DanhSachIdPhongBan = ids;
                var url    = !string.IsNullOrEmpty(input.Id) ? APIUrl.LoaiBaoCao.Sua : APIUrl.LoaiBaoCao.Them;
                var output = XuLyAPI.ApiJsonPost(url, input, false) as CommonOutput;
                if (output == null)
                {
                    throw new Exception(Message.LoiServer);
                }
                if (output.KetQua == 1)
                {
                    model.KetQua   = 1;
                    model.ThongBao = Message.ThanhCong;
                    ViewBag.KetQua = 1;
                    return(PartialView("_ThemCapNhatNhomTinPartial", new Models.NhomTinModel.NhomTinOutput.ThongTin()));
                }
                else
                {
                    return(PartialView("_ThemCapNhatNhomTinPartial", input2));
                }
            }
            catch (Exception ex)
            {
                model.KetQua   = 0;
                model.ThongBao = Message.ThatBai;
                return(PartialView("_ThemCapNhatNhomTinPartial", input2));
            }
        }