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

                return(result.IsValid
                    ? RedirectToAction("Index")
                    : _oops.OutPutError("Wellness", "Index", result.ErrorsList));
            }
            return(View(vm));
        }
Пример #2
0
        public async Task <IActionResult> Create([FromBody] CreateWellnessViewModel vm)
        {
            var result = await _services.CreateAsync(_mapper.Map <WellnessDTO>(vm));

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

                return(CreatedAtRoute("GetWellness", new { version = "1.0", controller = "Wellness", id = result.Result }, vm));
            }
            return(UnprocessableEntity(result.ErrorsList));
        }
Пример #3
0
        public async Task <IActionResult> Create(CreateWellnessViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var result = await _services.CreateAsync(_mapper.Map <WellnessDTO>(vm));

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

                    return(RedirectToAction("Index"));
                }
                TempData["ErrorsList"] = result.ErrorsList;
            }
            return(View(vm));
        }
Пример #4
0
        public async Task <IActionResult> Create([FromBody] CreateWellnessViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var result = await _services.CreateAsync(_mapper.Map <WellnessDTO>(vm));

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

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