Exemplo n.º 1
0
        // GET: Edition/Details/5
        public ActionResult Details(int id)
        {
            var getEditionById     = edition.GetById(id);
            EditionViewModel model = new EditionViewModel();

            model.InjectFrom(getEditionById);
            return(View(model));
        }
        // GET: Speakers/Details/5
        public ActionResult Details(int id)
        {
            Speakers         speakers = speakerService.GetSpeakerById(id);
            EditionViewModel model    = new EditionViewModel();

            model.InjectFrom(speakers);
            return(View(speakers));
        }
Exemplo n.º 3
0
        // GET: Editions/Edit/5
        public ActionResult Edit(int id)
        {
            var edition            = editionService.GetEditionById(id);
            EditionViewModel model = new EditionViewModel();

            model.InjectFrom(edition);
            return(View(model));
        }
Exemplo n.º 4
0
        // GET: Editions/Details/5
        public ActionResult Details(int id)
        {
            Editions         editions = editionService.GetEditionById(id);
            EditionViewModel model    = new EditionViewModel();

            model.InjectFrom(editions);
            return(View(editions));
        }
Exemplo n.º 5
0
        public ActionResult Edit(int id, EditionViewModel model)
        {
            Editions edition = new Editions();

            edition.InjectFrom(model);
            var editionToUpdate = editionService.UpdateEdition(edition);

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 6
0
        // GET: Editions/Edit/5
        public ActionResult Edit(int id)
        {
            var editionToUpdate    = editions.GetById(id);
            EditionViewModel model = new EditionViewModel();

            model.InjectFrom(editionToUpdate);

            return(View(model));
        }
Exemplo n.º 7
0
        public ActionResult Edit(int id, EditionViewModel model)
        {
            Editions edit = new Editions();

            edit.InjectFrom(model);
            var createNewEdition = edition.Update(edit);

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 8
0
        public ActionResult Delete(int id, EditionViewModel model)
        {
            Editions deleteEdition = new Editions();

            deleteEdition = edition.GetById(id);
            model.InjectFrom(deleteEdition);
            edition.DeleteEdition(deleteEdition);
            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 9
0
        public ActionResult Delete(int id, EditionViewModel model)
        {
            Editions editionToDelete = new Editions();

            editionToDelete = editionService.GetEditionById(id);
            model.InjectFrom(editionToDelete);
            editionService.Delete(editionToDelete);
            editionService.Save();
            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 10
0
        // GET: Editions/Delete/5
        public ActionResult Delete(int id)
        {
            var delete = edition.GetById(id);

            EditionViewModel model = new EditionViewModel();

            model.InjectFrom(delete);

            return(View(model));
        }
Exemplo n.º 11
0
        public ActionResult Create(EditionViewModel model)
        {
            if (ModelState.IsValid)
            {
                Editions newEdition = new Editions();
                newEdition.InjectFrom(model);

                var createEdition = edition.CreateEdition(newEdition);
                if (createEdition == null)
                {
                    ModelState.AddModelError("CompanyName", "Must be unique");
                    return(View(model));
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
        public ActionResult Edit(int id, EditionViewModel model)
        {
            if (ModelState.IsValid)
            {
                Editions editionToUpdate = new Editions();

                editionToUpdate.InjectFrom(model);

                var createNewEdition = editions.Update(editionToUpdate);

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View(model));
            }
        }
Exemplo n.º 13
0
        public ActionResult Create(EditionViewModel model)
        {
            if (ModelState.IsValid)
            {
                Editions edition = new Editions();

                edition.InjectFrom(model);

                var createNewEdition = editionService.AddEdition(edition);

                if (createNewEdition == null)
                {
                    ModelState.AddModelError("Name", "The Name must be unique!");

                    return(View(model));
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> PostEdition([FromBody] EditionViewModel edition)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var toSave = new Edition()
            {
                Id         = edition.Id,
                Season     = _context.Seasons.Where(s => s.Year == edition.Season)?.FirstOrDefault(),
                Tournement = _context.Tournements.Where(s => s.Name == edition.Tournement)?.FirstOrDefault(),
            };

            _context.Editions.Add(toSave);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEdition", new { id = edition.Id }, edition));
        }
Exemplo n.º 15
0
        public ActionResult Edit(int id, EditionViewModel model)
        {
            if (ModelState.IsValid)
            {
                Editions editionToUpdate = new Editions();

                editionToUpdate.InjectFrom(model);

                var createNewEdition = editions.Update(editionToUpdate);

                if (createNewEdition == null)
                {
                    ModelState.AddModelError("Name", "The Name must be unique!");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View(model));
            }
        }