Create() public static method

public static Create ( IRepository repository ) : OutcomeViewModel
repository IRepository
return OutcomeViewModel
示例#1
0
        public ActionResult Edit(Guid id, OutcomeViewModel model)
        {
            var outcomeToEdit = RepositoryFactory.OutcomeRepository.GetNullableById(id);

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

            outcomeToEdit.Name = model.Name;

            if (ModelState.IsValid)
            {
                if (model.File != null) //replace file if we have a new one
                {
                    var badgeImage = _fileService.Save(model.File, publicAccess: true);
                    outcomeToEdit.ImageUrl = badgeImage.Uri.AbsoluteUri;
                }

                RepositoryFactory.OutcomeRepository.EnsurePersistent(outcomeToEdit);

                Message = "Outcome Edited Successfully";

                return(RedirectToAction("Index"));
            }
            else
            {
                var viewModel = OutcomeViewModel.Create(Repository);
                viewModel.Name = model.Name;
                viewModel.Name = model.Description;

                return(View(viewModel));
            }
        }
示例#2
0
        public ActionResult Create(OutcomeViewModel model)
        {
            var outcomeToCreate = new Outcome {
                Name = model.Name, Description = model.Description
            };

            var outcomeImage = _fileService.Save(model.File, publicAccess: true);

            outcomeToCreate.ImageUrl = outcomeImage.Uri.AbsoluteUri;

            if (ModelState.IsValid)
            {
                RepositoryFactory.OutcomeRepository.EnsurePersistent(outcomeToCreate);

                Message = "Outcome Created Successfully";

                return(RedirectToAction("Index"));
            }
            else
            {
                var viewModel = OutcomeViewModel.Create(Repository);
                viewModel.Name        = model.Name;
                viewModel.Description = model.Description;

                return(View(viewModel));
            }
        }
示例#3
0
        //
        // GET: /Admin/Outcome/Edit/5
        public ActionResult Edit(Guid id)
        {
            var outcome = RepositoryFactory.OutcomeRepository.GetNullableById(id);

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

            var viewModel = OutcomeViewModel.Create(Repository);

            viewModel.Name        = outcome.Name;
            viewModel.Description = outcome.Description;
            viewModel.ImageUrl    = outcome.ImageUrl;

            return(View(viewModel));
        }
示例#4
0
        //
        // GET: /Admin/Outcome/Create
        public ActionResult Create()
        {
            var viewModel = OutcomeViewModel.Create(Repository);

            return(View(viewModel));
        }