Monday, June 25, 2018

Delete All Table from Master in Sql Server




EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"

Real Time Filtering by Javascript


Html:

Search Div:
<div class="col-xs-6">
                                        <div class="inputbox">
                                            <input type="text" id="myInput" placeholder="Search By Product Name .....">
                                            <input type="submit">
                                        </div>
                                    </div>


Content:
  @foreach (var item in Model)
                                {
                                    XDbContext db = new XDbContext();

                                    var Product = db.Products.Where(e => e.productID == item.ProductID)

                                                                  .FirstOrDefault();

                                    <div class="row ord platform">
                                        <div class="col-sm-2">
                                            <div class="order_img">
                                                <img src="@imageUrl@Product.ProductImage">
                                            </div>
                                        </div>

                                        <div class="col-sm-10">
                                            <div class="order_text search-me">
                                                <p><span>Product Name:</span><a href="@Url.Action("Details","Product",new { id = Product.productID, title = getEncodedTitle(Product.ProductTitle) })">@Product.ProductTitle</a> </p>
                                                <p><span>Date: @item.LastUpdated.GetValueOrDefault().ToString("dd MMM, yyyy")</span></p>

                                                <h4>AED @Product.SellingPrice</h4>
                                            </div>




                                        </div>

                                    </div>

                                }

Script: 

  $("#myInput").on("keyup", function() {
    var value = $(this).val().toLowerCase();
    $('.platform').hide();

      // Search and show
    $('.platform .search-me:contains("' + value + '")').closest('.platform').show();
  });

Sunday, June 24, 2018

Delete Method in asp.net mvc

 public ActionResult DeleteWishList(int id)
        {
            var search_wishlist = db.ProductWishLists.Find(id);
            db.ProductWishLists.Remove(search_wishlist);
            db.SaveChanges();
            return RedirectToAction("Index");
        }




#ssteam
we are making brotherhood

Sunday, June 3, 2018

Group By with Join in LINQ(SQL Expression)



var tempMostSellerCategory = from n in db.Temp_MostPopular
                                                 join m in db.Categories on n.CategoryID equals m.CategoryID
                                                 select new { n,m } into t1
                                                 group t1 by t1.n.CategoryID into g
                                                 select new
                                                 {
                                                     categoryid = g.FirstOrDefault().n.CategoryID,
                                                     title=g.FirstOrDefault().m.Title

                                                 };

Group By in LINQ



 List<Temp_LeftMenuCategory> categories = db.Temp_LeftMenuCategory.Where(e=>e.CatID==1 && e.Type== "Category").GroupBy(g => new { g.SubCatID })
                         .Select(g => g.FirstOrDefault())
                         .ToList();





Best Regards

#SSTEAM
we are making brotherhood