Beispiel #1
0
        public JsonResult Delete(int MetricId)
        {
            try
            {
                var results = _repository.GetUserMetric(MetricId, User.Identity.Name);

                if (results == null)
                {
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    return(Json("Failed to delete metric"));
                }

                _repository.DeleteUserMetric(results);

                if (_repository.SaveAll())
                {
                    Response.StatusCode = (int)HttpStatusCode.OK;
                    return(Json("Deleted Metric"));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to delete Metric", ex);
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json("Failed to delete Metric"));
            }

            Response.StatusCode = (int)HttpStatusCode.BadRequest;
            return(Json("Failed to delete Metric"));
        }