//GET: /ShopManagement

        public async Task <IActionResult> Index()
        {
            var user = await userManager.GetUserAsync(HttpContext.User);

            var seller = await db.Sellers.SingleOrDefaultAsync(x => x.Id == user.SellerID);

            // return Ok(seller);

            if (seller == null)
            {
                return(RedirectToAction(nameof(CreateShop)));
            }

            EditShopViewModel model = new EditShopViewModel
            {
                Countries      = SeedData.Get.Country,
                Name           = seller.Name,
                About          = seller.About,
                Home           = seller.Address,
                City           = seller.Address,
                Street         = seller.Address,
                Tel            = seller.Tel,
                Type           = (ShopType)Enum.Parse(typeof(ShopType), seller.ShopType),
                Message        = this.Message,
                LogoPath       = seller.Logo,
                BackgroundPath = seller.Cover
            };

            ViewBag.ID = seller.Id;
            return(View(model));
        }
        public async Task <IActionResult> Index(EditShopViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var user = await userManager.GetUserAsync(HttpContext.User);

            var seller = db.Sellers.FirstOrDefault(x => x.Id == user.SellerID);

            if (seller.Logo != model.LogoPath)
            {
                seller.Logo = model.LogoPath;
            }

            if (seller.Cover != model.BackgroundPath)
            {
                seller.Cover = model.BackgroundPath;
            }

            if (seller.Name != model.Name)
            {
                seller.Name = model.Name;
            }

            if (seller.ShopType != model.Type.ToString())
            {
                seller.ShopType = model.Type.ToString();
            }

            //Not yet: check address home/street/ county
            if (seller.Tel != model.Tel)
            {
                seller.Tel = model.Tel;
            }

            if (seller.About != model.About)
            {
                seller.About = model.About;
            }

            // if(seller.LogoImg != model.LogoPath)
            //     seller.LogoImg == model.LogoPath;

            await db.SaveChangesAsync();

            Message = "Your information has been updated.";

            return(RedirectToAction(nameof(Index)));
        }