コード例 #1
0
        public IActionResult Delete(int id)
        {
            try
            {
                _сatalogService.DeleteСatalog(id);

                string currentEmail = this.User.FindFirst(ClaimTypes.Name).Value;
                string userId       = _userHelper.GetUserId(currentEmail);

                if (userId == null)
                {
                    return(NotFound("User not found"));
                }

                _logger.LogInformation($"[{DateTime.Now.ToString()}]:[catalog/delete/{id}]:[info:delete catalog {id}]:[user:{userId}]");


                return(Ok(id));
            }
            catch (ValidationException ex)
            {
                _logger.LogError($"[{DateTime.Now.ToString()}]:[catalog/delete/{id}]:[error:{ex.Property}, {ex.Message}]");

                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                _logger.LogError($"[{DateTime.Now.ToString()}]:[catalog/delete/{id}]:[error:{ex}]");

                return(BadRequest());
            }
        }
コード例 #2
0
        public ActionResult Delete(int?id, int providerId, string searchSelectionString, string name)
        {
            try
            {
                _сatalogService.DeleteСatalog(id);

                string currentUserId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;
                _logger.LogInformation($"{DateTime.Now.ToString()}: User {currentUserId} deleted catalog {id}");

                return(RedirectToAction("Index", new { providerId, searchSelectionString, name }));
            }
            catch (ValidationException ex)
            {
                _logger.LogError($"{DateTime.Now.ToString()}: {ex.Property}, {ex.Message}");
                return(Content(ex.Message));
            }
        }