Exemple #1
0
        public async Task <IActionResult> AddManager(AddManagerModel model, IFormCollection image1)
        {
            // var webRoot = _environment.WebRootPath;
            //string managerId = Convert.ToString(image1["Id"]);
            string storePath = "/images/managers/";
            var    path      = Path.Combine(
                Directory.GetCurrentDirectory(), "wwwroot", "images", "managers",
                image1.Files[0].FileName);

            using (var stream = new FileStream(path, FileMode.Create))
            {
                await image1.Files[0].CopyToAsync(stream);
            }
            var manager = new Managers
            {
                ManagerName     = model.Name,
                DoB             = model.DoB,
                CountryId       = model.CountryId,
                TeamId          = model.TeamId,
                ManagerImageUrl = storePath + model.ImageUpload.FileName,
                BirthPlace      = model.BirthPlace
            };
            await _managerService.Create(manager);

            return(RedirectToAction("Index", "Managers"));
        }
Exemple #2
0
        public IActionResult Create()
        {
            var model = new AddManagerModel();
            var teams = _db.Teams.OrderBy(c => c.TeamName)
                        .Select(x => new { Id = x.Id, Value = x.TeamName });

            model.TeamList = new SelectList(teams, "Id", "Value");

            var countries = _db.Countries.OrderBy(c => c.Name)
                            .Select(x => new { Id = x.Id, Value = x.Name });

            model.CountryList = new SelectList(countries, "Id", "Value");

            return(View(model));
        }