コード例 #1
0
        public ActionResult Create(EditionViewModel model)
        {
            if (ModelState.IsValid)
            {
                Editions editionToCreate = new Editions();

                editionToCreate.InjectFrom(model);

                var createNewEdition = editions.CreateEdition(editionToCreate);

                if (createNewEdition == null)
                {
                    ModelState.AddModelError("Name", "The Name must be unique!");

                    return(View(model));
                }
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View(model));
            }
        }
コード例 #2
0
ファイル: EditionController.cs プロジェクト: kn1m/briefCore
        public async Task <HttpResponseMessage> Create([FromBody] EditionModel edition)
        {
            var result = await _editionService.CreateEdition(edition);

            return(result.CreateRespose(HttpStatusCode.Created, HttpStatusCode.BadRequest));
        }