Esempio n. 1
0
        public bool createShop(ShopList shop)
        {
            var shp = new Shp_Shop();

            shp.ShopImage  = shop.ShopImage;
            shp.ShopImage1 = shop.ShopImage1;
            shp.ShopImage2 = shop.ShopImage2;
            shp.ShopImage3 = shop.ShopImage3;
            shp.CategoryId = shop.CategoryId;
            shp.RCDate     = DateTime.Now.Date;
            shp.IsActive   = true;

            var shpT = new Shp_ShopTranslation();

            shpT.ShopTitle       = shop.ShopTitle;
            shpT.ShopDescription = shop.ShopDescription;
            shpT.ShopAddress     = shop.ShopAddress;
            shpT.LanguageId      = 1;
            shpT.RCDate          = DateTime.Now.Date;

            var shpD = new Shp_CardDiscount();

            shpD.CardDiscountPercentage = shop.CardDiscountPercentage;
            shpD.IsCurrent = true;
            shpD.RCDate    = DateTime.Now.Date;
            shpD.StartDate = DateTime.Now.Date;
            shp.Shp_ShopTranslation.Add(shpT);
            shp.Shp_CardDiscount.Add(shpD);
            db.Shp_Shop.Add(shp);

            bool isSuccess = (db.SaveChanges() > 0 ? true : false);

            return(isSuccess);
        }
Esempio n. 2
0
        public bool deleteShop(ShopList shop)
        {
            Shp_Shop shp = db.Shp_Shop.Select(x => x)
                           .Where(x => x.ShopId == shop.ShopId)
                           .FirstOrDefault();

            shp.IsActive = !shp.IsActive;
            shp.LADate   = DateTime.Now;
            bool isSuccess = (db.SaveChanges() > 0 ? true : false);

            return(isSuccess);
        }
Esempio n. 3
0
        public bool updateShop(ShopList shop)
        {
            Shp_Shop shp = db.Shp_Shop.Select(x => x)
                           .Where(x => x.ShopId == shop.ShopId)
                           .FirstOrDefault();

            shp.ShopImage  = shop.ShopImage;
            shp.ShopImage1 = shop.ShopImage1;
            shp.ShopImage2 = shop.ShopImage2;
            shp.ShopImage3 = shop.ShopImage3;
            shp.CategoryId = shop.CategoryId;
            shp.LADate     = DateTime.Now.Date;

            var shpT = shp.Shp_ShopTranslation.Select(x => x).FirstOrDefault();

            shpT.ShopTitle       = shop.ShopTitle;
            shpT.ShopDescription = shop.ShopDescription;
            shpT.ShopAddress     = shop.ShopAddress;
            shpT.LADate          = DateTime.Now.Date;

            var shpDSelect = shp.Shp_CardDiscount.Where(x => x.IsCurrent == true).Select(x => x).FirstOrDefault();

            if (shpDSelect.CardDiscountPercentage != shop.CardDiscountPercentage)
            {
                shpDSelect.IsCurrent = false;
                shpDSelect.LADate    = DateTime.Now.Date;
                shpDSelect.EndDate   = DateTime.Now.Date;

                var shpD = new Shp_CardDiscount();
                shpD.CardDiscountPercentage = shop.CardDiscountPercentage;
                shpD.IsCurrent = true;
                shpD.RCDate    = DateTime.Now.Date;
                shpD.StartDate = DateTime.Now.Date;
                shpD.ShopId    = shop.ShopId;
                db.Shp_CardDiscount.Add(shpD);
            }



            bool isSuccess = (db.SaveChanges() > 0 ? true : false);

            return(isSuccess);
        }