Create() public static method

public static Create ( IRepository repository ) : BadgeCategoryViewModel
repository IRepository
return BadgeCategoryViewModel
Esempio n. 1
0
        public ActionResult Edit(Guid id, BadgeCategoryViewModel model)
        {
            var badgeCategoryToEdit = RepositoryFactory.BadgeCategoryRepository.GetNullableById(id);

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

            badgeCategoryToEdit.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);
                    badgeCategoryToEdit.ImageUrl = badgeImage.Uri.AbsoluteUri;
                }

                RepositoryFactory.BadgeCategoryRepository.EnsurePersistent(badgeCategoryToEdit);

                Message = "BadgeCategory Edited Successfully";

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

                return(View(viewModel));
            }
        }
Esempio n. 2
0
        public ActionResult Create(BadgeCategoryViewModel model)
        {
            var badgeCategoryToCreate = new BadgeCategory {
                Name = model.Name
            };

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

            badgeCategoryToCreate.ImageUrl = badgeImage.Uri.AbsoluteUri;

            if (ModelState.IsValid)
            {
                RepositoryFactory.BadgeCategoryRepository.EnsurePersistent(badgeCategoryToCreate);

                Message = "BadgeCategory Created Successfully";

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

                return(View(viewModel));
            }
        }
Esempio n. 3
0
        //
        // GET: /Admin/BadgeCategory/Edit/5
        public ActionResult Edit(Guid id)
        {
            var badgeCategory = RepositoryFactory.BadgeCategoryRepository.GetNullableById(id);

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

            var viewModel = BadgeCategoryViewModel.Create(Repository);

            viewModel.Name     = badgeCategory.Name;
            viewModel.ImageUrl = badgeCategory.ImageUrl;

            return(View(viewModel));
        }
Esempio n. 4
0
        //
        // GET: /Admin/BadgeCategory/Create
        public ActionResult Create()
        {
            var viewModel = BadgeCategoryViewModel.Create(Repository);

            return(View(viewModel));
        }