コード例 #1
0
ファイル: AdminController.cs プロジェクト: bhavikgoyal/CKDemo
 public ActionResult Edit(Admin Obj_Admin)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var EmailPara   = new SqlParameter("@Email", Obj_Admin.Email);
             var AdminIdPara = new SqlParameter("@adminid", Obj_Admin.AdminId);
             var result      = context.Database.SqlQuery <Admin>("sp_Admin_CheckAdminExistsUpdate  @adminid,@Email", AdminIdPara, EmailPara).ToList();
             if (result.Count > 0)
             {
                 ViewBag.AdminExists = "Email is already exists.";
                 return(View(Obj_Admin));
             }
             else
             {
                 context.Admins.Attach(Obj_Admin);
                 context.Entry(Obj_Admin).State = System.Data.Entity.EntityState.Modified;
                 context.SaveChanges();
                 TempData["AdminSuccess"] = "Record has been update successfully.";
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.AdminExists = ex.Message;
         }
         return(View(Obj_Admin));
     }
 }
コード例 #2
0
 public ActionResult Create(Category Obj_Categories, string command)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var CategorynamePara = new SqlParameter("@Categoryname", Obj_Categories.CategoryName);
             var result           = context.Database.SqlQuery <Category>("sp_Category_CheckCategoryExists @Categoryname", CategorynamePara).ToList();
             if (result.Count > 0)
             {
                 ViewBag.CategoryExists = "Category name is already exists.";
                 ViewBag.Categories     = SessionUtilities.GetCategories();
                 return(View(Obj_Categories));
             }
             else
             {
                 Obj_Categories.CreatedOn = System.DateTime.Now;
                 Obj_Categories.IsDeleted = false;
                 context.Categories.Add(Obj_Categories);
                 context.SaveChanges();
                 TempData["CategorySuccess"] = "Record has been added successfully.";
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.Categories = ex.Message;
         }
         return(View(Obj_Categories));
     }
 }
コード例 #3
0
 public ActionResult Edit(Category Obj_Categories)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var CategoryName = new SqlParameter("@CategoryName", Obj_Categories.CategoryName);
             var CategoryId   = new SqlParameter("@CategoryId", Obj_Categories.CategoryId);
             var result       = context.Database.SqlQuery <Category>("sp_Category_CheckCategoryExistsUpdate  @CategoryId,@CategoryName", CategoryId, CategoryName).ToList();
             if (result.Count > 0)
             {
                 ViewBag.CategoryExists = "Category name is already exists.";
                 ViewBag.Categories     = SessionUtilities.GetCategories();
                 return(View(Obj_Categories));
             }
             else
             {
                 context.Categories.Attach(Obj_Categories);
                 context.Entry(Obj_Categories).State = System.Data.Entity.EntityState.Modified;
                 context.SaveChanges();
                 TempData["CategorySuccess"] = "Record has been update successfully.";
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.CategoryExists = ex.Message;
         }
         return(View(Obj_Categories));
     }
 }
コード例 #4
0
 public ActionResult Index(Int32?Businessid)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var BusinessidPara        = new SqlParameter("@Businessid", Businessid);
             var obj_BusinessDirectory = context.Database.SqlQuery <BusinessDirectory>("sp_BusinessDirectory_select @Businessid", BusinessidPara).FirstOrDefault();
             ViewBag.ListingName = obj_BusinessDirectory.BusinessName;
             return(View());
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.BusinessReview = ex.Message;
         }
         return(View());
     }
     //string listingName = "";
     //using (BusinessDirectoryCtl dbLIsting = new BusinessDirectoryCtl())
     //{
     //    System.Data.DataTable dt = dbLIsting.selectdatatable(Businessid);
     //    if (dt.Rows.Count > 0)
     //    {
     //        listingName = Convert.ToString(dt.Rows[0]["BusinessName"]);
     //    }
     //}
     //ViewBag.ListingName = listingName;
     //return View();
 }
コード例 #5
0
        public ActionResult Create(BusinessReview Obj_BusinessReview, string command)
        {
            try
            {
                using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
                {
                    Obj_BusinessReview.AddedOn   = System.DateTime.Now;
                    Obj_BusinessReview.IsDeleted = false;
                    context.BusinessReviews.Add(Obj_BusinessReview);
                    context.SaveChanges();
                    TempData["BusinessReviewSuccess"] = "Record has been added successfully.";
                    return(RedirectToAction("Index", new { Businessid = Obj_BusinessReview.BusinessID }));
                }
            }
            catch (Exception ex)
            {
                if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
                {
                    ViewBag.BusinessReviewError = ex.Message;
                }
                return(View(Obj_BusinessReview));
            }
            //using (BusinessReviewCtl db = new BusinessReviewCtl())
            //{

            //    db.insert(Obj_BusinessReview);
            //    return RedirectToAction("Index", new { Businessid = Obj_BusinessReview.Businessid });
            //}
        }
コード例 #6
0
 public ActionResult Edit(Location Obj_Location)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var LocationidPara   = new SqlParameter("@Locationid", Obj_Location.LocationId);
             var LocationnamePara = new SqlParameter("@Locationname", Obj_Location.LocationName);
             var LocationurlPara  = new SqlParameter("@Locationurl", Obj_Location.LocationURL);
             var result           = context.Database.SqlQuery <Location>("sp_Location_CheckLocationExists_Update  @Locationid,@Locationname,@Locationurl", LocationidPara, LocationnamePara, LocationurlPara).ToList();
             if (result.Count > 0)
             {
                 ViewBag.LocationExists = "Location name is already exists.";
                 ViewBag.StateData      = SessionUtilities.GetState();
                 return(View(Obj_Location));
             }
             else
             {
                 context.Locations.Attach(Obj_Location);
                 context.Entry(Obj_Location).State = System.Data.Entity.EntityState.Modified;
                 context.SaveChanges();
                 TempData["LocationSuccess"] = "Record has been update successfully.";
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.LocationExists = ex.Message;
         }
         return(View(Obj_Location));
     }
 }
コード例 #7
0
 public ActionResult Edit(Int32?Businessreviewid)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var            BusinessreviewidPara = new SqlParameter("@Businessreviewid", Businessreviewid);
             BusinessReview Obj_BusinessReview   = context.Database.SqlQuery <BusinessReview>("sp_BusinessReview_select @Businessreviewid", BusinessreviewidPara).FirstOrDefault();
             return(View(Obj_BusinessReview));
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.BusinessReviewError = ex.Message;
         }
         return(View());
     }
     //using (BusinessReviewCtl db = new BusinessReviewCtl())
     //{
     //    BusinessReviewClass obj_BusinessReview = db.selectById(Businessreviewid);
     //    return View(obj_BusinessReview);
     //}
 }
コード例 #8
0
 public ActionResult Edit(BusinessReview Obj_BusinessReview)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             context.BusinessReviews.Attach(Obj_BusinessReview);
             context.Entry(Obj_BusinessReview).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
             TempData["BusinessReviewSuccess"] = "Record has been update successfully.";
             return(RedirectToAction("Index", new { Businessid = Obj_BusinessReview.BusinessID }));
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.BusinessReviewError = ex.Message;
         }
         return(View(Obj_BusinessReview));
     }
     //using (BusinessReviewCtl db = new BusinessReviewCtl())
     //{
     //    db.update(Obj_BusinessReview);
     //    return RedirectToAction("Index", new { Businessid = Obj_BusinessReview.Businessid });
     //}
 }
コード例 #9
0
 public ActionResult Delete(Int32 AdsBannerId)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var       AdsBannerIdPara = new SqlParameter("@adsbannerid", AdsBannerId);
             AdsBanner obj_AdsBanner   = context.Database.SqlQuery <AdsBanner>("sp_AdsBanner_select @adsbannerid", AdsBannerIdPara).FirstOrDefault();
             obj_AdsBanner.IsDeleted            = true;
             context.Entry(obj_AdsBanner).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
             var adsbannerSequenceidPara = new SqlParameter("@adsbannerid", obj_AdsBanner.AdsBannerID);
             context.Database.ExecuteSqlCommand("sp_AdsBanner_delete @adsbannerid", AdsBannerIdPara);
             TempData["AdsBannerSuccess"] = "Record has been deleted successfully.";
             return(RedirectToAction("Index"));
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             TempData["AdsBannerError"] = ex.Message;
         }
         return(RedirectToAction("Index"));
     }
 }
コード例 #10
0
 public ActionResult Create(Location Obj_Location, string command)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var LocationnamePara = new SqlParameter("@Locationname", Obj_Location.LocationName);
             var LocationurlPara  = new SqlParameter("@Locationurl", Obj_Location.LocationURL);
             var result           = context.Database.SqlQuery <Location>("sp_Location_CheckLocationExists @Locationname,@Locationurl", LocationnamePara, LocationurlPara).ToList();
             if (result.Count > 0)
             {
                 ViewBag.LocationExists = "Location name is already exists.";
                 ViewBag.StateData      = SessionUtilities.GetState();
                 return(View(Obj_Location));
             }
             else
             {
                 Obj_Location.CreatedOn = System.DateTime.Now;
                 Obj_Location.IsDeleted = false;
                 context.Locations.Add(Obj_Location);
                 context.SaveChanges();
                 TempData["LocationSuccess"] = "Record has been added successfully.";
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.LocationExists = ex.Message;
         }
         return(View(Obj_Location));
     }
 }
コード例 #11
0
ファイル: AdminController.cs プロジェクト: bhavikgoyal/CKDemo
 public ActionResult Create(Admin Obj_Admin, string command)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var EmailPara = new SqlParameter("@Email", Obj_Admin.Email);
             var result    = context.Database.SqlQuery <Admin>("sp_Admin_CheckAdminExists @Email", EmailPara).ToList();
             if (result.Count > 0)
             {
                 ViewBag.AdminExists = "Email is already exists.";
                 return(View(Obj_Admin));
             }
             else
             {
                 Obj_Admin.CreatedOn = System.DateTime.Now;
                 Obj_Admin.IsDeleted = false;
                 context.Admins.Add(Obj_Admin);
                 context.SaveChanges();
                 TempData["AdminSuccess"] = "Record has been added successfully.";
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.AdminExists = ex.Message;
         }
         return(View(Obj_Admin));
     }
 }
コード例 #12
0
 public ActionResult Edit(Int32?Categoryid)
 {
     using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
     {
         try
         {
             var CategoryidPara           = new SqlParameter("@Categoryid", Categoryid);
             var Result                   = context.Database.SqlQuery <Category>("sp_Categories_Id_Name_selectall @Categoryid", CategoryidPara).ToList();
             List <SelectListItem> IdName = new List <SelectListItem>();
             for (int i = 0; i < Result.Count; i++)
             {
                 SelectListItem obj = new SelectListItem();
                 obj.Text  = Convert.ToString(Result[i].CategoryName);
                 obj.Value = Convert.ToString(Result[i].CategoryId);
                 IdName.Add(obj);
             }
             ViewBag.Categories = IdName;
             var CategoryId     = new SqlParameter("@Categoryid", Categoryid);
             var ResultCategory = context.Database.SqlQuery <Category>("sp_Categories_select @Categoryid", CategoryId).FirstOrDefault();
             return(View(ResultCategory));
         }
         catch (Exception ex)
         {
             if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
             {
                 ViewBag.Categories = ex.Message;
             }
             return(View());
         }
     }
 }
コード例 #13
0
 public ActionResult Delete(Int32?Businessreviewid)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var            BusinessreviewidPara = new SqlParameter("@Businessreviewid", Businessreviewid);
             BusinessReview obj_BusinessReview   = context.Database.SqlQuery <BusinessReview>("sp_BusinessReview_select @Businessreviewid", BusinessreviewidPara).FirstOrDefault();
             obj_BusinessReview.IsDeleted            = true;
             context.Entry(obj_BusinessReview).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
             TempData["BusinessReviewSuccess"] = "Record has been deleted successfully.";
             return(RedirectToAction("Index", new { Businessid = obj_BusinessReview.BusinessID }));
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.BusinessReviewError = ex.Message;
         }
         return(View());
     }
     //using (BusinessReviewCtl db = new BusinessReviewCtl())
     //{
     //    db.delete(Businessreviewid);
     //    return RedirectToAction("Index");
     //}
 }
コード例 #14
0
 public ActionResult Edit(Int32?Websitebannerid)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var           WebsitebanneridPara = new SqlParameter("@Websitebannerid", Websitebannerid);
             WebsiteBanner obj_WebsiteBanner   = context.Database.SqlQuery <WebsiteBanner>("sp_WebsiteBanner_select @Websitebannerid", WebsitebanneridPara).FirstOrDefault();
             return(View(obj_WebsiteBanner));
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.WebsiteBannerError = ex.Message;
         }
         return(View(new Admin()));
     }
     //using (WebsiteBannerCtl db = new WebsiteBannerCtl())
     //{
     //    WebsiteBannerClass obj_WebsiteBanner = db.selectById(Websitebannerid);
     //    return View(obj_WebsiteBanner);
     //}
 }
コード例 #15
0
 public ActionResult Edit(WebsiteBanner Obj_WebsiteBanner, HttpPostedFileBase BannerImage)
 {
     try
     {
         string BannerName = string.Empty;
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var           WebsitebanneridPara     = new SqlParameter("@Websitebannerid", Obj_WebsiteBanner.WebsiteBannerID);
             WebsiteBanner obj_WebsiteBannerResult = context.Database.SqlQuery <WebsiteBanner>("sp_WebsiteBanner_select @Websitebannerid", WebsitebanneridPara).FirstOrDefault();
             if (SessionUtilities.SaveImage(BannerImage, "Banner"))
             {
                 BannerName = Path.GetFileName(BannerImage.FileName);
                 Obj_WebsiteBanner.BannerImage = BannerName;
             }
             else
             {
                 Obj_WebsiteBanner.BannerImage = obj_WebsiteBannerResult.BannerImage;
             }
             var WebsitebannerSequenceidPara = new SqlParameter("@Websitebannerid", Obj_WebsiteBanner.WebsiteBannerID);
             var WebsitebannerSequencePara   = new SqlParameter("@Sequence", Obj_WebsiteBanner.Sequence);
             context.Database.ExecuteSqlCommand("sp_WebsiteBanner_updateSequenceEdit @Sequence,@Websitebannerid", WebsitebannerSequencePara, WebsitebannerSequenceidPara);
             context.WebsiteBanners.Attach(Obj_WebsiteBanner);
             context.Entry(Obj_WebsiteBanner).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
             TempData["WebsiteBannerSuccess"] = "Record has been update successfully.";
             return(RedirectToAction("Index"));
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.WebsiteBannerError = ex.Message;
         }
         return(View(Obj_WebsiteBanner));
     }
     //try
     //{
     //    string BannerName = string.Empty;
     //    using (WebsiteBannerCtl db = new WebsiteBannerCtl())
     //    {
     //        if (SessionUtilities.SaveImage(BannerImage, "Banner"))
     //        {
     //            BannerName = Path.GetFileName(BannerImage.FileName);
     //            Obj_WebsiteBanner.BannerImage = BannerName;
     //        }
     //        db.update(Obj_WebsiteBanner);
     //        TempData["WebsiteBannerSuccess"] = "Record has been updated successfully.";
     //    }
     //    return RedirectToAction("Index");
     //}
     //catch (Exception ex)
     //{
     //    return View(Obj_WebsiteBanner);
     //}
 }
コード例 #16
0
        public ActionResult Edit(AdsBanner Obj_AdsBanner, HttpPostedFileBase AdsBannerImage)
        {
            try
            {
                string AdsBannerName = string.Empty;
                using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
                {
                    var AdsBannerNamePara     = new SqlParameter("@adsbannername", Obj_AdsBanner.AdsBannerName);
                    var AdsBannerVendorIdPara = new SqlParameter("@vendorid", Obj_AdsBanner.VendorID);
                    var AdsBannerIdPara       = new SqlParameter("@adsbannerid", Obj_AdsBanner.AdsBannerID);
                    var result = context.Database.SqlQuery <AdsBanner>("sp_AdsBanner_CheckVendorExistsUpdate @adsbannername,@vendorid,@adsbannerid", AdsBannerNamePara, AdsBannerVendorIdPara, AdsBannerIdPara).ToList();
                    if (result.Count > 0)
                    {
                        ViewBag.AdsBannerExists = "Banner name is already exists.";
                        GetCateory();
                        GetVendor();
                        GetPosition();
                        return(View(Obj_AdsBanner));
                    }
                    else
                    {
                        var       AdsGetBannerIdPara = new SqlParameter("@adsbannerid", Obj_AdsBanner.AdsBannerID);
                        AdsBanner obj_AdsBanners     = context.Database.SqlQuery <AdsBanner>("sp_AdsBanner_select @adsbannerid", AdsGetBannerIdPara).FirstOrDefault();
                        if (SessionUtilities.SaveImage(AdsBannerImage, "AdsBanner", Obj_AdsBanner.AdsBannerName.Trim()))
                        {
                            AdsBannerName = Path.GetFileName(AdsBannerImage.FileName);
                            Obj_AdsBanner.AdsBannerImage = AdsBannerName;
                        }
                        else
                        {
                            Obj_AdsBanner.AdsBannerImage = obj_AdsBanners.AdsBannerImage;
                        }

                        var adsbannerSequenceidPara = new SqlParameter("@adsbannerid", Obj_AdsBanner.AdsBannerID);
                        var adsbannerSequencePara   = new SqlParameter("@priority", Obj_AdsBanner.Priority);
                        context.Database.ExecuteSqlCommand("sp_AdsBanner_updateSequenceEdit @priority,@adsbannerid", adsbannerSequencePara, adsbannerSequenceidPara);
                        context.AdsBanners.Attach(Obj_AdsBanner);
                        context.Entry(Obj_AdsBanner).State = System.Data.Entity.EntityState.Modified;
                        context.SaveChanges();
                        TempData["AdsBannerSuccess"] = "Record has been update successfully.";
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
                {
                    ViewBag.AdsBannerExists = ex.Message;
                }
                return(View(Obj_AdsBanner));
            }
        }
コード例 #17
0
 public ActionResult Create(Location Obj_Location, string command)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var LocationnamePara = new SqlParameter("@Locationname", Obj_Location.LocationName);
             var result           = context.Database.SqlQuery <Location>("sp_Location_CheckLocationExists @Locationname", LocationnamePara).ToList();
             if (result.Count > 0)
             {
                 ViewBag.LocationExists = "Location name is already exists.";
                 DataTable dt     = new DataTable();
                 var       Result = context.Database.SqlQuery <StateData>("sp_StateData_SelectAllForSelectInAddEditLocation").ToList();
                 dt = SessionUtilities.LINQResultToDataTable(Result);
                 List <SelectListItem> lstObj = new List <SelectListItem>();
                 SelectListItem        sl     = new SelectListItem();
                 sl.Text     = "--Please Select--";
                 sl.Value    = "0";
                 sl.Selected = true;
                 lstObj.Add(sl);
                 foreach (DataRow dr in dt.Rows)
                 {
                     sl          = new SelectListItem();
                     sl.Text     = Convert.ToString(dr["FullName"]);
                     sl.Value    = Convert.ToString(dr["FullName"]);
                     sl.Selected = false;
                     lstObj.Add(sl);
                 }
                 ViewBag.StateData = lstObj;
                 return(View(Obj_Location));
             }
             else
             {
                 Obj_Location.CreatedOn = System.DateTime.Now;
                 Obj_Location.IsDeleted = false;
                 context.Locations.Add(Obj_Location);
                 context.SaveChanges();
                 TempData["LocationSuccess"] = "Record has been added successfully.";
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.LocationExists = ex.Message;
         }
         return(View(Obj_Location));
     }
 }
コード例 #18
0
        public ActionResult Create(WebsiteBanner Obj_WebsiteBanner, string command, HttpPostedFileBase BannerImage)
        {
            try
            {
                string BannerName = string.Empty;
                using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
                {
                    if (SessionUtilities.SaveImage(BannerImage, "Banner"))
                    {
                        BannerName = Path.GetFileName(BannerImage.FileName);
                        Obj_WebsiteBanner.BannerImage = BannerName;
                    }
                    Obj_WebsiteBanner.CreatedOn = System.DateTime.Now;
                    Obj_WebsiteBanner.IsDeleted = false;
                    context.WebsiteBanners.Add(Obj_WebsiteBanner);
                    context.SaveChanges();
                    var WebsitebannerSequenceidPara = new SqlParameter("@websitebannerid", Obj_WebsiteBanner.WebsiteBannerID);
                    context.Database.ExecuteSqlCommand("sp_WebsiteBanner_UpdateSequence @websitebannerid", WebsitebannerSequenceidPara);
                    TempData["WebsiteBannerSuccess"] = "Record has been added successfully.";
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
                {
                    ViewBag.WebsiteBannerError = ex.Message;
                }
                return(View(Obj_WebsiteBanner));
            }
            //try
            //{
            //    string BannerName = string.Empty;
            //    using (WebsiteBannerCtl db = new WebsiteBannerCtl())
            //    {
            //        if (SessionUtilities.SaveImage(BannerImage, "Banner"))
            //        {
            //            BannerName = Path.GetFileName(BannerImage.FileName);
            //            Obj_WebsiteBanner.BannerImage = BannerName;
            //        }
            //        db.insert(Obj_WebsiteBanner);
            //        TempData["WebsiteBannerSuccess"] = "Record has been added successfully.";
            //    }
            //    return RedirectToAction("Index");

            //}
            //catch (Exception ex)
            //{
            //    return View(Obj_WebsiteBanner);
            //}
        }
コード例 #19
0
 public ActionResult Edit(Int32?Businessid)
 {
     using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
     {
         try
         {
             Int32?Categoryid     = 0;
             var   CategoryidPara = new SqlParameter("@Categoryid", Categoryid);
             var   CategoryResult = context.Database.SqlQuery <Category>("sp_Categories_Id_Name_selectall @Categoryid", CategoryidPara).ToList();
             List <SelectListItem> CategoryIdName = new List <SelectListItem>();
             for (int i = 0; i < CategoryResult.Count; i++)
             {
                 SelectListItem obj = new SelectListItem();
                 obj.Text  = Convert.ToString(CategoryResult[i].CategoryName);
                 obj.Value = Convert.ToString(CategoryResult[i].CategoryId);
                 CategoryIdName.Add(obj);
             }
             ViewBag.Categories = CategoryIdName;
             var LocationResult = context.Database.SqlQuery <Location>("sp_Location_Id_Name_selectall").ToList();
             List <SelectListItem> LocationIdName = new List <SelectListItem>();
             for (int i = 0; i < LocationResult.Count; i++)
             {
                 SelectListItem obj = new SelectListItem();
                 obj.Text  = Convert.ToString(LocationResult[i].LocationName);
                 obj.Value = Convert.ToString(LocationResult[i].LocationId);
                 LocationIdName.Add(obj);
             }
             ViewBag.Locations = LocationIdName;
             var BusinessidPara = new SqlParameter("@Businessid", Businessid);
             BusinessDirectory obj_BusinessDirectory = context.Database.SqlQuery <BusinessDirectory>("sp_BusinessDirectory_select @Businessid", BusinessidPara).FirstOrDefault();
             var CategoryIdWithComma      = string.Empty;
             var BusinessCategoryidPara   = new SqlParameter("@Businessid", Businessid);
             var CategoryResultByBusiness = context.Database.SqlQuery <BusinessCategory>("sp_BusinessCategory_select @Businessid", BusinessCategoryidPara).ToList();
             for (int i = 0; i < CategoryResultByBusiness.Count; i++)
             {
                 CategoryIdWithComma += CategoryResultByBusiness[i].CategoryID + ",";
             }
             ViewBag.CategoryIdWithComma = CategoryIdWithComma;
             return(View(obj_BusinessDirectory));
         }
         catch (Exception ex)
         {
             if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
             {
                 TempData["BusinessError"] = ex.Message;
             }
             return(View());
         }
     }
 }
コード例 #20
0
 public ActionResult Create(AdsBanner Obj_AdsBanner, string command, HttpPostedFileBase AdsBannerImage)
 {
     try
     {
         string AdsBannerName = string.Empty;
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var AdsBannerNamePara     = new SqlParameter("@adsbannername", Obj_AdsBanner.AdsBannerName);
             var AdsBannerVendorIdPara = new SqlParameter("@vendorid", Obj_AdsBanner.VendorID);
             var result = context.Database.SqlQuery <AdsBanner>("sp_AdsBanner_CheckAdminExists @adsbannername,@vendorid", AdsBannerNamePara, AdsBannerVendorIdPara).ToList();
             if (result.Count > 0)
             {
                 ViewBag.AdsBannerExists = "Banner name is already exists.";
                 GetCateory();
                 GetVendor();
                 GetPosition();
                 return(View(Obj_AdsBanner));
             }
             else
             {
                 GetCateory();
                 GetVendor();
                 GetPosition();
                 if (SessionUtilities.SaveImage(AdsBannerImage, "AdsBanner", Obj_AdsBanner.AdsBannerName.Trim()))
                 {
                     AdsBannerName = Path.GetFileName(AdsBannerImage.FileName);
                     Obj_AdsBanner.AdsBannerImage = AdsBannerName;
                 }
                 Obj_AdsBanner.CreateAt  = System.DateTime.Now;
                 Obj_AdsBanner.IsDeleted = false;
                 context.AdsBanners.Add(Obj_AdsBanner);
                 context.SaveChanges();
                 var adsBannersequenceIdpara = new SqlParameter("@adsbannerid", Obj_AdsBanner.AdsBannerID);
                 context.Database.ExecuteSqlCommand("sp_AdsBanner_UpdateSequence @adsbannerid", adsBannersequenceIdpara);
                 TempData["AdsBannerSuccess"] = "Record has been added successfully.";
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.AdsBannerExists = ex.Message;
         }
         return(View(Obj_AdsBanner));
     }
 }
コード例 #21
0
 public JsonResult SelectGalleryImages(Int32?Businessid)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var BusinessidPara        = new SqlParameter("@Businessid", Businessid);
             var obj_BusinessDirectory = context.Database.SqlQuery <Listview>("sp_BusinessGallery_SelectImagesByBusiness @Businessid", BusinessidPara).ToList();
             return(Json(obj_BusinessDirectory, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         return(Json("", JsonRequestBehavior.AllowGet));
     }
 }
コード例 #22
0
 public ActionResult Create(Category Obj_Categories, string command)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var CategorynamePara = new SqlParameter("@Categoryname", Obj_Categories.CategoryName);
             var result           = context.Database.SqlQuery <Category>("sp_Category_CheckCategoryExists @Categoryname", CategorynamePara).ToList();
             if (result.Count > 0)
             {
                 ViewBag.CategoryExists = "Category name is already exists.";
                 Int32?Categoryid             = 0;
                 var   CategoryidPara         = new SqlParameter("@Categoryid", Categoryid);
                 var   Result                 = context.Database.SqlQuery <Category>("sp_Categories_Id_Name_selectall @Categoryid", CategoryidPara).ToList();
                 List <SelectListItem> IdName = new List <SelectListItem>();
                 for (int i = 0; i < Result.Count; i++)
                 {
                     SelectListItem obj = new SelectListItem();
                     obj.Text  = Convert.ToString(Result[i].CategoryName);
                     obj.Value = Convert.ToString(Result[i].CategoryId);
                     IdName.Add(obj);
                 }
                 ViewBag.Categories = IdName;
                 return(View(Obj_Categories));
             }
             else
             {
                 Obj_Categories.CreatedOn = System.DateTime.Now;
                 Obj_Categories.IsDeleted = false;
                 context.Categories.Add(Obj_Categories);
                 context.SaveChanges();
                 TempData["AdminSuccess"] = "Record has been added successfully.";
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.Categories = ex.Message;
         }
         return(View(Obj_Categories));
     }
 }
コード例 #23
0
ファイル: AdminController.cs プロジェクト: bhavikgoyal/CKDemo
 public JsonResult Indexpaging(Int64 PageSize, Int64 PageIndex, string Search)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var PageSizePara  = new SqlParameter("@PageSize", PageSize);
             var PageIndexPara = new SqlParameter("@PageIndex", PageIndex);
             var SearchPara    = new SqlParameter("@Search", Search);
             var result        = context.Database.SqlQuery <Listview>("sp_Admin_selectIndexPaging @PageSize,@PageIndex,@Search", PageSizePara, PageIndexPara, SearchPara).ToList();
             return(Json(SessionUtilities.ConvertDataTableTojSonString(SessionUtilities.LINQResultToDataTable(result)), JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         return(Json(string.Format("Exception {0}", ex.Message), JsonRequestBehavior.AllowGet));
     }
 }
コード例 #24
0
 public static List <SelectListItem> GetCategories()
 {
     using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
     {
         Int32?Categoryid             = 0;
         var   CategoryidPara         = new SqlParameter("@Categoryid", Categoryid);
         var   Result                 = context.Database.SqlQuery <Category>("sp_Categories_Id_Name_selectall @Categoryid", CategoryidPara).ToList();
         List <SelectListItem> IdName = new List <SelectListItem>();
         for (int i = 0; i < Result.Count; i++)
         {
             SelectListItem obj = new SelectListItem();
             obj.Text  = Convert.ToString(Result[i].CategoryName);
             obj.Value = Convert.ToString(Result[i].CategoryId);
             IdName.Add(obj);
         }
         return(IdName);
     }
 }
コード例 #25
0
 public ActionResult Edit(Category Obj_Categories)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var CategoryName = new SqlParameter("@CategoryName", Obj_Categories.CategoryName);
             var CategoryId   = new SqlParameter("@CategoryId", Obj_Categories.CategoryId);
             var result       = context.Database.SqlQuery <Category>("sp_Category_CheckCategoryExistsUpdate  @CategoryId,@CategoryName", CategoryId, CategoryName).ToList();
             if (result.Count > 0)
             {
                 ViewBag.CategoryExists = "Category name is already exists.";
                 var CategoryidPara           = new SqlParameter("@Categoryid", Obj_Categories.CategoryId);
                 var Result                   = context.Database.SqlQuery <Category>("sp_Categories_Id_Name_selectall @Categoryid", CategoryidPara).ToList();
                 List <SelectListItem> IdName = new List <SelectListItem>();
                 for (int i = 0; i < Result.Count; i++)
                 {
                     SelectListItem obj = new SelectListItem();
                     obj.Text  = Convert.ToString(Result[i].CategoryName);
                     obj.Value = Convert.ToString(Result[i].CategoryId);
                     IdName.Add(obj);
                 }
                 ViewBag.Categories = IdName;
                 return(View(Obj_Categories));
             }
             else
             {
                 context.Categories.Attach(Obj_Categories);
                 context.Entry(Obj_Categories).State = System.Data.Entity.EntityState.Modified;
                 context.SaveChanges();
                 TempData["CategorySuccess"] = "Record has been update successfully.";
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.CategoryExists = ex.Message;
         }
         return(View(Obj_Categories));
     }
 }
コード例 #26
0
 public ActionResult CheckUserNamePass(string email, string password)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var EmailPara    = new SqlParameter("@Email", email);
             var PasswordPara = new SqlParameter("@Password", password);
             var result       = context.Database.SqlQuery <Admin>("sp_admin_CheckUserNamePassLogin @Email,@Password", EmailPara, PasswordPara).FirstOrDefault();
             if (!string.IsNullOrEmpty(Convert.ToString(result)))
             {
                 SessionUtilities.AdminId  = result.AdminId.ToString();
                 SessionUtilities.Username = result.Username.ToString();
                 return(Json(string.Format("Success, {0} ", result.AdminId.ToString())));
             }
             else
             {
                 return(Json(string.Format("Error")));
             }
         }
     }
     catch (Exception)
     {
         return(Json(string.Format("Error")));
     }
     //AdminClass obj1 = new AdminClass();
     //AdminCtl obj = new AdminCtl();
     //obj1.Email = email;
     //obj1.Password = password;
     //DataTable dt = new DataTable();
     //List<AdminCtl> viewModelList = new List<AdminCtl>();
     //dt = obj.CheckUserNamePass(obj1);
     //if (dt != null && dt.Rows.Count > 0)
     //{
     //    SessionUtilities.AdminId = dt.Rows[0]["AdminId"].ToString();
     //    SessionUtilities.Username = dt.Rows[0]["Username"].ToString();
     //    return Json(string.Format("Success, {0} ", dt.Rows[0]["AdminId"].ToString()));
     //}
     //else
     //{
     //    return Json(viewModelList, JsonRequestBehavior.AllowGet);
     //}
 }
コード例 #27
0
 public ActionResult Create()
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             ViewBag.StateData = SessionUtilities.GetState();
             return(View());
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.LocationExists = ex.Message;
         }
         return(View());
     }
 }
コード例 #28
0
ファイル: AdminController.cs プロジェクト: bhavikgoyal/CKDemo
 public ActionResult Edit(Int32?AdminId)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var   AdminIdPara = new SqlParameter("@adminid", AdminId);
             Admin obj_Admin   = context.Database.SqlQuery <Admin>("sp_Admin_select @adminid", AdminIdPara).FirstOrDefault();
             return(View(obj_Admin));
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.AdminExists = ex.Message;
         }
         return(View(new Admin()));
     }
 }
コード例 #29
0
 public ActionResult Edit(Int32?VendorId)
 {
     try
     {
         using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
         {
             var    VendorIdPara = new SqlParameter("@vendorid", VendorId);
             Vendor obj_Vendor   = context.Database.SqlQuery <Vendor>("sp_Vendor_select @vendorid", VendorIdPara).FirstOrDefault();
             return(View(obj_Vendor));
         }
     }
     catch (Exception ex)
     {
         if (!ex.Message.Contains("See 'EntityValidationErrors' property"))
         {
             ViewBag.VendorExists = ex.Message;
         }
         return(View(new Vendor()));
     }
 }
コード例 #30
0
 public void GetVendor()
 {
     using (var context = new ChossonKallahAdmin.EF6.ChossonKallah())
     {
         var VendorResult = context.Database.SqlQuery <Vendor>("sp_Vendor_Id_Name_selectall").ToList();
         List <SelectListItem> VendorIdName = new List <SelectListItem>();
         SelectListItem        slVendor     = new SelectListItem();
         slVendor.Text     = "--Please Select--";
         slVendor.Value    = "0";
         slVendor.Selected = true;
         VendorIdName.Add(slVendor);
         for (int i = 0; i < VendorResult.Count; i++)
         {
             SelectListItem obj = new SelectListItem();
             obj.Text  = Convert.ToString(VendorResult[i].VendorName);
             obj.Value = Convert.ToString(VendorResult[i].VendorID);
             VendorIdName.Add(obj);
         }
         ViewBag.Vendors = VendorIdName;
     }
 }