예제 #1
0
        public IActionResult CreateClinic([FromBody] Clinic clinic)
        {
            if (clinic == null)
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var createdClinic = _ClinicRepository.AddClinic(clinic);

            return(Created("clinic", createdClinic));
        }
예제 #2
0
        public ActionResult AddClinic(AddEditClinicViewModel addClinic)
        {
            if (ModelState.IsValid)
            {
                // add clinic
                var clinic  = Mapper.Map <AddEditClinicViewModel, Clinic>(addClinic);
                var created = _clinicRepository.AddClinic(clinic);

                if (created)
                {
                    return(RedirectToAction("Index"));
                }

                return(HttpNotFound());
            }
            else
            {
                return(View());
            }
        }