Esempio n. 1
0
        public async Task <IActionResult> UpdateProfile()
        {
            var User = await GetCurrentUserAsync();

            var model = new EditVendorProfileViewModel();

            model.VendorUsers = User;
            model.Coupons     = await context.Coupon
                                .Where(v => v.VendorUser == User)
                                .OrderBy(t => t.Title).ToListAsync();

            model.Albums = await context.Album
                           .Where(v => v.VendorUser == User)
                           .OrderBy(a => a.Title).ToListAsync();

            model.Categories = await context.Category
                               .OrderBy(cc => cc.Name).ToListAsync();

            model.VenCat = await context.VendorCategory
                           .Where(v => v.VendorUser == User)
                           .OrderBy(c => c.Category.Name).ToListAsync();


            return(View(model));
        }
Esempio n. 2
0
        public async Task <IActionResult> UpdateProfile(EditVendorProfileViewModel model, [FromRoute] string Id)
        {
            var User = await GetCurrentUserAsync();

            VendorUser vu = context.VendorUser.Where(i => i.Id == Id).SingleOrDefault();

            vu.FirstName     = model.VendorUsers.FirstName;
            vu.LastName      = model.VendorUsers.LastName;
            vu.CompanyName   = model.VendorUsers.CompanyName;
            vu.Description   = model.VendorUsers.Description;
            vu.StreetAddress = model.VendorUsers.StreetAddress;
            vu.Zip           = model.VendorUsers.Zip;
            vu.ProfileImage  = model.VendorUsers.ProfileImage;
            vu.Website       = model.VendorUsers.Website;

            if (ModelState.IsValid)
            {
                context.Add(vu);
            }

            try
            {
                context.SaveChanges();
                return(RedirectToAction("Profile", "Vendor"));
            }

            catch (DbUpdateException)
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> AddCat(EditVendorProfileViewModel model, [FromBody] int [] cat)
        {
            model.CatListing = cat;
            var User = await GetCurrentUserAsync();

            if (ModelState.IsValid)
            {
                foreach (int catid in model.CatListing)
                {
                    VendorCategory vct = (from vc in context.VendorCategory
                                          where vc.CategoryId == catid && vc.VendorUser == User
                                          select vc).SingleOrDefault();

                    if (vct == null)
                    {
                        context.VendorCategory.Add(new VendorCategory {
                            VendorUser = User, CategoryId = catid
                        });
                    }
                }
            }
            try
            {
                await context.SaveChangesAsync();

                return(View());
                //return RedirectToAction("Profile", new RouteValueDictionary(
                //new { controller = "Vendor", action = "Profile"}));
            }

            catch (DbUpdateException)
            {
                return(RedirectToAction("Index", new RouteValueDictionary(
                                            new { controller = "Home", action = "Index" })));
            }
        }