예제 #1
0
        public ActionResult CreateOrUpdate(ActorMovieViewModel model)
        {
            if (!ValidateForm(model))
            {
                model.MovieSelectList = GetRelatedEntitiesList();
                CreateNotification(ActionResultType.Failure);
                return(View("CreateOrUpdate", model));
            }

            var actorParams = Mapper.Map <ActorMovieParams>(model);

            if (actorParams.ActorId == 0)
            {
                var actorIdString = TempData["actorId"].ToString();
                int actorId;
                if (Int32.TryParse(actorIdString, out actorId))
                {
                    actorParams.ActorId = actorId;
                }
            }

            var actorMovie = _actorMovieService.CreateOrUpdate(actorParams);

            CreateNotification(ActionResultType.Success);

            return(RedirectToAction("Update", new { actorMovie.Id }));
        }
예제 #2
0
 public bool ValidateForm(ActorMovieViewModel model)
 {
     if (string.IsNullOrEmpty(model.CharacterName))
     {
         ModelState.AddModelError("CharacterName", "Bu alanın doldurulması zorunludur");
     }
     return(ModelState.IsValid);
 }
예제 #3
0
        public ActionResult Create()
        {
            var model = new ActorMovieViewModel(Status.Active);

            model.MovieSelectList = GetRelatedEntitiesList();

            TempData["actorId"] = Request.QueryString.Get("actorId");

            return(View("CreateOrUpdate", model));
        }