public async Task <IActionResult> Create(AwardViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var result = await _services.CreateAsync(_mapper.Map <DirectoryDTO>(vm));

                return(result.IsValid
                    ? RedirectToAction("Index")
                    : _oops.OutPutError("Award", "Index", result.ErrorsList));
            }
            return(View(vm));
        }
示例#2
0
        public async Task <IActionResult> Create([FromBody] CreateAwardViewModel vm)
        {
            var result = await _services.CreateAsync(_mapper.Map <DirectoryDTO>(vm));

            if (result.IsValid)
            {
                await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Award);

                return(CreatedAtRoute("GetAward", new { version = "1.0", controller = "Award", id = result.Result }, vm));
            }
            return(UnprocessableEntity(result.ErrorsList));
        }
        public async Task <IActionResult> Create([FromBody] CreateAwardViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var result = await _services.CreateAsync(_mapper.Map <DirectoryDTO>(vm));

                if (result.IsValid)
                {
                    await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Award);

                    return(Ok(result));
                }
                return(BadRequest(result));
            }
            return(BadRequest());
        }
示例#4
0
        public async Task <IActionResult> Create(CreateAwardViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var result = await _services.CreateAsync(_mapper.Map <DirectoryDTO>(vm));

                if (result.IsValid)
                {
                    await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Award);

                    return(RedirectToAction("Index"));
                }
                TempData["ErrorsList"] = result.ErrorsList;
            }
            return(View(vm));
        }