コード例 #1
0
        public async Task <IActionResult> CreateSubordinateConfirmed(CreateSubordinateSubdivisionViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var result = await _services.CreateSubordinateSubdivisionAsync(_mapper.Map <SubdivisionDTO>(vm));

                return(result.IsValid
                    ? RedirectToAction("Details", new { id = vm.HashIdSubordinate })
                    : _oops.OutPutError("Subdivision", "Index", result.ErrorsList));
            }
            return(View(vm));
        }
        public async Task <IActionResult> CreateSubordinateSubdivision([FromBody] CreateSubordinateSubdivisionViewModel vm)
        {
            var result = await _services.CreateSubordinateSubdivisionAsync(_mapper.Map <CreateSubordinateSubdivisionDTO>(vm));

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

                return(CreatedAtRoute("GetSubdivision", new { version = "1.0", controller = "Subdivision", id = result.Result }, vm));
            }
            return(UnprocessableEntity(result.ErrorsList));
        }
コード例 #3
0
        public async Task <IActionResult> CreateSubordinateConfirmed(CreateSubordinateSubdivisionViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var result = await _services.CreateSubordinateSubdivisionAsync(_mapper.Map <CreateSubordinateSubdivisionDTO>(vm));

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

                    return(RedirectToAction("Details", new { id = vm.HashIdMain }));
                }
                TempData["ErrorsList"] = result.ErrorsList;
            }
            return(View(vm));
        }
        public async Task <IActionResult> CreateSubordinateSubdivision([FromBody] CreateSubordinateSubdivisionViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var result = await _services.CreateSubordinateSubdivisionAsync(_mapper.Map <CreateSubordinateSubdivisionDTO>(vm));

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

                    return(Ok(result));
                }
                return(BadRequest(result));
            }
            return(BadRequest());
        }