コード例 #1
0
        public async Task <bool> AddGender(GenderParameter genderName)
        {
            var gender = Mapper.Map <GenderParameter, Gender>(genderName);

            UnitOfWork.Repo.Add(gender);
            return(await UnitOfWork.SaveChanges() > 0);
        }
コード例 #2
0
        public async Task <IActionResult> Create(GenderParameter gender)
        {
            if (ModelState.IsValid)
            {
                var isCreated = await _genderBusiness.AddGender(gender);

                if (isCreated)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(gender));
        }
コード例 #3
0
        public async Task <IActionResult> AddGender([FromBody] GenderParameter gender)
        {
            if (ModelState.IsValid)
            {
                var isAdded = await _genderBusiness.AddGender(gender);

                if (isAdded)
                {
                    return(Ok("Saved Successfully"));
                }
            }
            return(BadRequest(ModelState));
        }
コード例 #4
0
        public async Task <IActionResult> AddGender([FromBody] GenderParameter gender)
        {
            try
            {
                var isAdded = await _genderBusiness.AddGender(gender);

                if (isAdded)
                {
                    return(Ok("Saved Successfully"));
                }

                return(NoContent());
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }