Ejemplo n.º 1
0
        public ActionResult Create(Gender gender)
        {
            if (ModelState.IsValid)
            {
                Service.Add(gender);
                return(RedirectToAction("Index"));
            }

            return(View(gender));
        }
Ejemplo n.º 2
0
        // POST: api/Genders
        public HttpResponseMessage Post(Gender body)
        {
            using (GenderService genderService = new GenderService(new DataContext()))
            {
                if (!ModelState.IsValid)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }

                genderService.Add(body);
                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
        }