Пример #1
0
        public JsonResult OnCreate(string pUserName, string pAvata, int pMarketType, string pEmail, string pFullName, string pMobile, string pSumary, bool pActive = true)
        {
            var mMarket = new Market()
            {
                Date     = DateTime.Now,
                BirthDay = DateTime.Now,
                UserName = Ultility.LocDau2(pUserName.Trim()),
                Avata    = pAvata,
                Email    = pEmail,
                FullName = pFullName,
                Gender   = true,
                Phone    = pMobile,
                Role     = pMarketType,
                Status   = pActive,
                Sumary   = pSumary
            };

            MpStartEntities.AddToMarket(mMarket);
            MpStartEntities.SaveChanges();
            //lay danh sách nhom san pham
            var mList = ProductsService.getProductTypeParent();

            foreach (ProductType it in mList)
            {
                MarketProductType mMarketProductType = new MarketProductType()
                {
                    Date        = DateTime.Now,
                    Name        = it.Name,
                    Detail      = it.Name,
                    Parent      = it.ID,
                    Status      = true,
                    Visible     = true,
                    Number      = 1,
                    MarketId    = mMarket.ID,
                    MarketName  = mMarket.UserName,
                    ImageBanner = it.ImageBanner
                };
                MpStartEntities.AddToMarketProductType(mMarketProductType);
            }
            MpStartEntities.SaveChanges();
            return(Json(new { code = 1, message = "Lưu cửa hàng thành công." }));
        }