Create() public static method

public static Create ( IRepository repository ) : ServiceMessageViewModel
repository IRepository
return ServiceMessageViewModel
        public ActionResult Create(ServiceMessage serviceMessage)
        {
            var serviceMessageToCreate = new ServiceMessage();

            TransferValues(serviceMessage, serviceMessageToCreate);

            if (ModelState.IsValid)
            {
                _serviceMessageRepository.EnsurePersistent(serviceMessageToCreate);

                // invalidate the cache
                System.Web.HttpContext.Current.Cache.Remove(CacheKey);

                Message = "ServiceMessage Created Successfully";

                return(RedirectToAction("Index"));
            }
            else
            {
                var viewModel = ServiceMessageViewModel.Create(Repository);
                viewModel.ServiceMessage = serviceMessage;

                return(View(viewModel));
            }
        }
        public ActionResult Edit(int id, ServiceMessage serviceMessage)
        {
            var serviceMessageToEdit = _serviceMessageRepository.GetNullableById(id);

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

            TransferValues(serviceMessage, serviceMessageToEdit);

            if (ModelState.IsValid)
            {
                _serviceMessageRepository.EnsurePersistent(serviceMessageToEdit);

                // invalidate the cache
                System.Web.HttpContext.Current.Cache.Remove(CacheKey);

                Message = "ServiceMessage Edited Successfully";

                return(RedirectToAction("Index"));
            }
            else
            {
                var viewModel = ServiceMessageViewModel.Create(Repository);
                viewModel.ServiceMessage = serviceMessage;

                return(View(viewModel));
            }
        }
        public ActionResult Edit(int id)
        {
            var serviceMessage = _serviceMessageRepository.GetNullableById(id);

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

            var viewModel = ServiceMessageViewModel.Create(Repository);

            viewModel.ServiceMessage = serviceMessage;

            return(View(viewModel));
        }
        public ActionResult Create()
        {
            var viewModel = ServiceMessageViewModel.Create(Repository);

            return(View(viewModel));
        }