Exemple #1
0
        public int AddBanner(etblBannerM prop)
        {
            try
            {
                if (prop.sDescription != null)
                {
                    prop.sDescription = prop.sDescription.Replace("\t", "");
                }

                prop.iActionBy    = ((OneFineRateBLL.BL_Login.UserDetails)(Session["UserDetails"])).iUserId;
                prop.dtActionDate = DateTime.Now;

                if (!string.IsNullOrEmpty(prop.sLinkController) && !string.IsNullOrEmpty(prop.sLinkAction))
                {
                    if (prop.sLinkController != "Select" && prop.sLinkAction != "Select")
                    {
                        prop.sLinkId = "../" + prop.sLinkController + "/" + prop.sLinkAction;
                    }
                }

                prop.cstatus = "A";
                int result = BL_tblBannerM.AddRecord(prop);
                return(result);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #2
0
        public static etblBannerM GetBannerDetailsByID(int BannerId)
        {
            etblBannerM promorec = new etblBannerM();

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                var rec = (from m in db.tblBannerMs
                           join c in db.tblUserMs on m.iActionBy equals c.iUserId
                           select new
                {
                    m.iBannerId,
                    m.sBannerName,
                    m.sBannerType,
                    m.sDescription,
                    m.sTextPosition,
                    m.sLinkId,
                    m.cstatus,
                    m.sImgUrl,
                    m.iResolutionH,
                    m.iResolutionW,
                    m.UniqueAzureFileName,
                    UserName = c.sFirstName + " " + c.sLastName
                }
                           ).Where(u => u.iBannerId == BannerId).AsQueryable();
                var data = rec.ToList();
                promorec = (etblBannerM)OneFineRateAppUtil.clsUtils.ConvertToObject(data[0], promorec);
                return(promorec);
            }
        }
Exemple #3
0
        public ActionResult Add()
        {
            etblBannerM obj = new etblBannerM();

            obj.Mode    = "Add";
            obj.heading = "Add Banner";
            return(PartialView("pvBanner", obj));
        }
Exemple #4
0
        //Add new Banner
        public static int AddRecord(etblBannerM eobj)
        {
            int retval = 0;

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    bool chkPageBottom = false;
                    bool chkExists     = db.tblBannerMs.Any(
                        p => p.sBannerName == eobj.sBannerName
                        //&& p.sBannerType == eobj.sBannerType
                        && p.cstatus == eobj.cstatus
                        );
                    if (eobj.sBannerType == "Page Bottom")
                    {
                        chkPageBottom = db.tblBannerMs.Any(
                            p => p.sBannerType == eobj.sBannerType
                            );
                    }

                    if (chkExists != true)
                    {
                        if (chkPageBottom != true)
                        {
                            OneFineRate.tblBannerM dbuser = (OneFineRate.tblBannerM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblBannerM());
                            db.tblBannerMs.Add(dbuser);
                            db.SaveChanges();
                            retval = 1;
                        }
                        else
                        {
                            retval = 3;
                        }
                    }
                    else
                    {
                        retval = 2;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(retval);
        }
Exemple #5
0
        public ActionResult Edit(int Id)
        {
            etblBannerM obj = new etblBannerM();

            obj = BL_tblBannerM.GetBannerDetailsByID(Id);
            //if (obj.sLinkId != null)
            //{
            //    string[] arr = obj.sLinkId.Split('/');
            //    obj.sLinkController = arr[1].ToString();
            //    obj.sLinkAction = arr[2].ToString();
            //}


            obj.Mode    = "Edit";
            obj.heading = "Edit Banner";
            return(PartialView("pvBanner", obj));
        }
Exemple #6
0
        public ActionResult Delete(int Id)
        {
            string strReturn = string.Empty;

            try
            {
                etblBannerM prop = new etblBannerM();
                prop = BL_tblBannerM.GetBannerDetailsByID(Id);
                if (prop.cstatus == "A")
                {
                    prop.cstatus = "I";
                }
                else if (prop.cstatus == "I")
                {
                    prop.cstatus = "A";
                }

                prop.iActionBy    = ((OneFineRateBLL.BL_Login.UserDetails)(Session["UserDetails"])).iUserId;
                prop.dtActionDate = DateTime.Now;
                int val = BL_tblBannerM.DeleteRecord(prop);
                if (val == 1)
                {
                    if (prop.cstatus == "I")
                    {
                        TempData["msg"] = "Disabled successfully";
                        // return Json(new { st = 0, msg = "Disabled successfully" }, JsonRequestBehavior.AllowGet);
                    }
                    else
                    {
                        TempData["msg"] = "Enabled successfully";
                        // return Json(new { st = 0, msg = "Enabled successfully" }, JsonRequestBehavior.AllowGet);
                    }
                }
                else
                {
                    TempData["msg"] = "Kindly try after some time";
                    //return Json(new { st = 0, msg = "Kindly try after some time" }, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception)
            {
            }
            return(RedirectToAction("Index"));
        }
Exemple #7
0
        public int EditBanner(etblBannerM prop)
        {
            try
            {
                prop.sDescription = prop.sDescription.Replace("\t", "");
                prop.iActionBy    = ((OneFineRateBLL.BL_Login.UserDetails)(Session["UserDetails"])).iUserId;
                prop.dtActionDate = DateTime.Now;
                //if (prop.sLinkController != "Select" && prop.sLinkAction != "Select")
                //{
                //    prop.sLinkId = "../" + prop.sLinkController + "/" + prop.sLinkAction;
                //}

                int result = BL_tblBannerM.UpdateRecord(prop);
                return(result);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #8
0
        //Update new Banner
        public static int UpdateRecord(etblBannerM eobj)
        {
            int retval = 0;

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    OneFineRate.tblBannerM obj = (OneFineRate.tblBannerM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblBannerM());
                    db.tblBannerMs.Attach(obj);
                    db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    retval = 1;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(retval);
        }
Exemple #9
0
        public ActionResult Save(etblBannerM prop)
        {
            var    file      = Request.Files;
            string strReturn = string.Empty;
            int    val       = 0;

            foreach (ModelState modelState in ViewData.ModelState.Values)
            {
                foreach (ModelError error in modelState.Errors)
                {
                    string str;
                    str = "a";
                    // DoSomethingWith(error);
                }
            }
            prop.sDescription = prop.sDescription == null ? prop.sDescription : prop.sDescription.ToString().Replace("<p>", "").Replace("</p>", "");

            if (ModelState.IsValid)
            {
                if (prop.bannerImage != null)
                {
                    if (IsValideImage(prop.bannerImage))
                    {
                        using (MemoryStream target = new MemoryStream())
                        {
                            prop.bannerImage.InputStream.CopyTo(target);
                            byte[] data = target.ToArray();

                            var uniqueFileName = Guid.NewGuid().ToString() + Path.GetExtension(prop.bannerImage.FileName);

                            var currentUploadedFileUrl = clsUtils.fnUploadFileINBlobStorage("banner", uniqueFileName, data, true);

                            System.Drawing.Image image = System.Drawing.Image.FromStream(new System.IO.MemoryStream(data));
                            //prop.bIsMapped = false;
                            prop.sImgUrl             = "banner" + "/" + uniqueFileName;
                            prop.UniqueAzureFileName = uniqueFileName;
                            prop.iResolutionH        = (short)image.Height;
                            prop.iResolutionW        = (short)image.Width;
                        }
                        if (prop.Mode == "Add")
                        {
                            val = AddBanner(prop);
                        }

                        if (prop.Mode == "Edit")
                        {
                            val = EditBanner(prop);
                        }

                        if (val == 1)
                        {
                            if (prop.Mode == "Add")
                            {
                                TempData["msg"] = "Added Successfully";
                                // return Json(new { st = 0, msg = "Added Successfully" }, JsonRequestBehavior.AllowGet);
                            }

                            if (prop.Mode == "Edit")
                            {
                                TempData["msg"] = "Updated Successfully";
                                // return Json(new { st = 0, msg = "Updated Successfully" }, JsonRequestBehavior.AllowGet);
                            }
                        }
                        if (val == 2)
                        {
                            if (prop.Mode == "Add")
                            {
                                TempData["ERROR"] = "Banner already exists with same Name";
                                //return Json(new { st = 0, msg = "Banner already exists with same Name" }, JsonRequestBehavior.AllowGet);
                            }
                        }
                        if (val == 3)
                        {
                            if (prop.Mode == "Add")
                            {
                                TempData["ERROR"] = "Banner for page bottom already exists";
                                //return Json(new { st = 0, msg = "Banner already exists with same Name" }, JsonRequestBehavior.AllowGet);
                            }
                        }
                    }
                    else
                    {
                        TempData["ERROR"] = "Incorrect Format.Only jpg png gif jpeg formats are allowed.";
                        //return Json(new { st = 0, msg = "Incorrect Format.Only jpg png gif jpeg formats are allowed." }, JsonRequestBehavior.AllowGet);
                    }
                }
                else
                {
                    if (prop.Mode == "Edit")
                    {
                        val = EditBanner(prop);
                        if (val == 1)
                        {
                            TempData["msg"] = "Updated Successfully";
                            // return Json(new { st = 0, msg = "Updated Successfully" }, JsonRequestBehavior.AllowGet);
                        }
                        if (val == 2 || val == 3)
                        {
                            TempData["ERROR"] = "Banner for page bottom already exists";
                            //return Json(new { st = 0, msg = "Banner already exists with same Name" }, JsonRequestBehavior.AllowGet);
                        }
                    }
                    else if (prop.Mode == "Add")
                    {
                        val = AddBanner(prop);
                        if (val == 1)
                        {
                            TempData["msg"] = "Added Successfully";
                            // return Json(new { st = 0, msg = "Updated Successfully" }, JsonRequestBehavior.AllowGet);
                        }
                        else if (val == 2)
                        {
                            TempData["ERROR"] = "Banner already exists with same Name";
                            //return Json(new { st = 0, msg = "Banner already exists with same Name" }, JsonRequestBehavior.AllowGet);
                        }
                        else if (val == 3)
                        {
                            TempData["ERROR"] = "Banner for page bottom already exists";
                        }
                    }
                }
            }
            return(RedirectToAction("Index"));
            //return Json(new { st = 1, msg = true }, JsonRequestBehavior.AllowGet);
        }