예제 #1
0
        public ActionResult CreateUpdateBanner(Banner banner, HttpPostedFileBase fileBanner)
        {
            if (accessDetail != null && (accessDetail.access["all"] || accessDetail.access["create"]))
            {
                if (banner.id == 0 && fileBanner == null)
                {
                    return(Json(new { success = false, message = "Vui lòng chọn hình ảnh" }));
                }

                banner.image = "";
                if (fileBanner != null)
                {
                    string LocalPath = "";
                    banner.image_link = new AzureHelper().UploadImageToAzure(AllConstant.FoldderName_Banner, fileBanner, currentUser.name, ref LocalPath);
                    banner.image      = fileBanner.FileName;
                }
                banner.ngay_tao       = DateTime.Now;
                banner.nguoi_tao      = currentUser.name;
                banner.ngay_cap_nhat  = DateTime.Now;
                banner.nguoi_cap_nhat = currentUser.name;
                string rs = new Banner_DAO().CreateUpdate(banner, currentUser.name, AppConfigs.MCCConnectionString);
                if (!string.IsNullOrEmpty(rs))
                {
                    string[] StringSplit = new string[] { "@@" };
                    if (rs.Split(StringSplit, StringSplitOptions.None)[0] == "false")
                    {
                        return(Json(new { success = false, message = rs.Split(StringSplit, StringSplitOptions.None)[1] }));
                    }
                    using (var dbConn = MCC.Helpers.OrmliteConnection.openConn())
                    {
                        var data = dbConn.FirstOrDefault <Banner>("ma_banner={0}".Params(rs.Split(StringSplit, StringSplitOptions.None)[1]));
                        return(Json(new { success = true, data = data }));
                    }
                }
            }
            return(RedirectToAction("NoAccess", "Error"));
        }
예제 #2
0
 public Banner_BCL()
 {
     mBannerDao = new Banner_DAO();
 }