예제 #1
0
        public async Task <ActionResult> Create(CustomerTagViewModel model)
        {
            try {
                if (ModelState.IsValid)
                {
                    var item = await _businessManager.CreateCustomerTag(_mapper.Map <CustomerTagDto>(model));

                    if (item == null)
                    {
                        return(BadRequest());
                    }

                    return(RedirectToAction(nameof(Index)));
                }
            } catch (Exception er) {
                _logger.LogError(er, er.Message);
            }

            return(View(model));
        }
예제 #2
0
        public async Task <ActionResult> Edit(long id, CustomerTagViewModel model)
        {
            try {
                if (ModelState.IsValid)
                {
                    var dto  = _mapper.Map <CustomerTagDto>(model);
                    var item = await _businessManager.UpdateCustomerTag(id, dto);

                    if (item == null)
                    {
                        return(NotFound());
                    }

                    return(RedirectToAction(nameof(Edit), new { id = item.Id }));
                }
            } catch (Exception er) {
                _logger.LogError(er, er.Message);
            }

            return(View(model));
        }