ViewModel for the ExperienceType class
Esempio n. 1
0
        public static ExperienceTypeViewModel Create(IRepository repository)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var viewModel = new ExperienceTypeViewModel();

            return(viewModel);
        }
Esempio n. 2
0
        //
        // GET: /Admin/ExperienceType/Edit/5
        public ActionResult Edit(Guid id)
        {
            var experienceType = RepositoryFactory.ExperienceTypeRepository.GetNullableById(id);

            if (experienceType == null)
            {
                return(RedirectToAction("Index"));
            }

            var viewModel = ExperienceTypeViewModel.Create(Repository);

            viewModel.Name = experienceType.Name;
            viewModel.Icon = experienceType.Icon;

            return(View(viewModel));
        }
Esempio n. 3
0
        public ActionResult Create(ExperienceTypeViewModel model)
        {
            var experienceTypeToCreate = new ExperienceType();
            TransferValues(model, experienceTypeToCreate);

            if (ModelState.IsValid)
            {
                RepositoryFactory.ExperienceTypeRepository.EnsurePersistent(experienceTypeToCreate);

                Message = "ExperienceType Created Successfully";

                return RedirectToAction("Index");
            }
            else
            {
                return View(model);
            }
        }
Esempio n. 4
0
        public ActionResult Create(ExperienceTypeViewModel model)
        {
            var experienceTypeToCreate = new ExperienceType();

            TransferValues(model, experienceTypeToCreate);

            if (ModelState.IsValid)
            {
                RepositoryFactory.ExperienceTypeRepository.EnsurePersistent(experienceTypeToCreate);

                Message = "ExperienceType Created Successfully";

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(model));
            }
        }
Esempio n. 5
0
        public ActionResult Edit(Guid id, ExperienceTypeViewModel model)
        {
            var experienceTypeToEdit = RepositoryFactory.ExperienceTypeRepository.GetNullableById(id);

            if (experienceTypeToEdit == null)
            {
                return(RedirectToAction("Index"));
            }

            TransferValues(model, experienceTypeToEdit);

            if (ModelState.IsValid)
            {
                RepositoryFactory.ExperienceTypeRepository.EnsurePersistent(experienceTypeToEdit);

                Message = "ExperienceType Edited Successfully";

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(model));
            }
        }
Esempio n. 6
0
        public ActionResult Edit(Guid id, ExperienceTypeViewModel model)
        {
            var experienceTypeToEdit = RepositoryFactory.ExperienceTypeRepository.GetNullableById(id);

            if (experienceTypeToEdit == null) return RedirectToAction("Index");

            TransferValues(model, experienceTypeToEdit);

            if (ModelState.IsValid)
            {
                RepositoryFactory.ExperienceTypeRepository.EnsurePersistent(experienceTypeToEdit);

                Message = "ExperienceType Edited Successfully";

                return RedirectToAction("Index");
            }
            else
            {
                return View(model);
            }
        }
Esempio n. 7
0
        public static ExperienceTypeViewModel Create(IRepository repository)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var viewModel = new ExperienceTypeViewModel();

            return viewModel;
        }
Esempio n. 8
0
 /// <summary>
 /// Transfer editable values from source to destination
 /// </summary>
 private static void TransferValues(ExperienceTypeViewModel source, ExperienceType destination)
 {
     destination.Name = source.Name;
     destination.Icon = source.Icon;
 }
Esempio n. 9
0
        //
        // GET: /Admin/ExperienceType/Create
        public ActionResult Create()
        {
            var viewModel = ExperienceTypeViewModel.Create(Repository);

            return(View(viewModel));
        }
Esempio n. 10
0
 /// <summary>
 /// Transfer editable values from source to destination
 /// </summary>
 private static void TransferValues(ExperienceTypeViewModel source, ExperienceType destination)
 {
     destination.Name = source.Name;
     destination.Icon = source.Icon;
 }