Esempio n. 1
0
        public ActionResult EditMetadata(EditMetadataViewModel metadata)
        {
            if (ModelState.IsValid)
            {
                var result = _metadataService.EditMetadata(FilmViewerMapper.Mapper.Map <MetadataDto>(metadata));
                switch (result)
                {
                case AddResult.DuplicateElement:
                    ModelState.AddModelError("Duplicate", Resources.MetadataAlreadyExist);
                    return(View(metadata));

                case AddResult.UnknownError:
                    ModelState.AddModelError("UnknownError", Resources.UnknownError);
                    return(View(metadata));

                case AddResult.Added:
                    TempData[UserMessages.UserMessage] = new MessageViewModel()
                    {
                        CssClass = "alert-success",
                        Message  = Resources.MetadataEditedSuccesfully
                    };
                    break;
                }
                return(RedirectToAction("MetadataView"));
            }
            return(View(metadata));
        }