예제 #1
0
        public IActionResult Create()
        {
            SalonsVM salon = new SalonsVM()
            {
                Country = new SelectList(GetAllCountrys(), "CountryId", "Name")
            };

            return(PartialView("_Create", salon));
        }
예제 #2
0
        public IActionResult Edit(SalonsVM model)
        {
            model.Country = new SelectList(GetAllCountrys(), "CountryId", "Name");
            model.City    = new SelectList(GetAllCitiesByCountryId(model.CountryId), "CityId", "Name");
            var user = _userManager.GetUserAsync(HttpContext.User).Result;

            if (model.SaloonId == 0)
            {
                return(NotFound());
            }
            if (model == null)
            {
                if (model.SaloonId != 0)
                {
                    return(PartialView("Edit", new { Id = model.SaloonId }));
                }
                else
                {
                    return(PartialView("_IndexPartial"));
                }
            }
            var salon = _context.Salons.Where(s => s.SaloonId == model.SaloonId).FirstOrDefault();

            salon.Name              = model.Name;
            salon.CountryId         = model.CountryId;
            salon.CityId            = model.CityId;
            salon.OpeningTime       = model.OpeningTime;
            salon.ClosingTime       = model.ClosingTime;
            salon.Address           = model.Address;
            salon.Phone             = model.Phone;
            salon.Mobile            = model.Mobile;
            salon.Website           = model.Website;
            salon.ApplicationUserId = user.Id.ToString();

            _context.Salons.Update(salon);
            _context.SaveChanges();

            return(PartialView("Edit", model));
        }
예제 #3
0
        public async Task <IActionResult> Create(SalonsVM model)
        {
            model.Country = new SelectList(GetAllCountrys(), "CountryId", "Name");
            model.City    = new SelectList(GetAllCitiesByCountryId(model.CountryId), "CityId", "Name");


            if (!ModelState.IsValid)
            {
                var error = ViewData.ModelState.Values.ToList();
                return(PartialView("_Create", model));
            }
            Salon salon = new Salon();

            if (model == null)
            {
                return(PartialView("_Create", salon));
            }
            var user = await _userManager.GetUserAsync(HttpContext.User);

            salon.Name              = model.Name;
            salon.CountryId         = model.CountryId;
            salon.CityId            = model.CityId;
            salon.OpeningTime       = model.OpeningTime;
            salon.ClosingTime       = model.ClosingTime;
            salon.Email             = model.Email;
            salon.Website           = model.Website;
            salon.Address           = model.Address;
            salon.Phone             = model.Phone;
            salon.Mobile            = model.Mobile;
            salon.ApplicationUserId = user.Id.ToString();

            _context.Salons.Add(salon);
            await _context.SaveChangesAsync();

            return(PartialView("_Create", model));
        }