public LevelOfImportance DeleteLevelOfImportance(int id)
        {
            LevelOfImportance levelOfImportance = db.LevelOfImportance.Find(id);

            if (levelOfImportance == null)
            {
                _loggerService.CreateLog("Jordan", "LevelOfImportance", "Delete", string.Empty, $"LevelOfImportance {id} not found to delete.");
                return(null);
            }

            try
            {
                db.LevelOfImportance.Remove(levelOfImportance);
                db.SaveChanges();

                _loggerService.CreateLog("Jordan", "LevelOfImportance", "Delete", levelOfImportance.ToString());
            }
            catch (Exception e)
            {
                _loggerService.CreateLog("Jordan", "LevelOfImportance", "Delete", levelOfImportance.ToString(), "Error deleting levelOfImportance: " + e.Message);
                return(null);
            }

            return(levelOfImportance);
        }
        public LevelOfImportance InsertLevelOfImportance(LevelOfImportance levelOfImportance)
        {
            try
            {
                levelOfImportance.CreatedDateTime = DateTime.Now;
                db.LevelOfImportance.Add(levelOfImportance);
                db.SaveChanges();

                _loggerService.CreateLog("Jordan", "LevelOfImportance", "Create", levelOfImportance.ToString());

                return(levelOfImportance);
            }
            catch (Exception e)
            {
                _loggerService.CreateLog("Jordan", "LevelOfImportance", "Create", levelOfImportance.ToString(), "Error creating this record: " + e.Message);
                return(null);
            }
        }
        public IHttpActionResult Update(int id, LevelOfImportance levelOfImportance)
        {
            _loggerService.CreateLog(_user, "API", "LevelOfImportanceController", "LevelOfImportance", "Update", levelOfImportance.ToString(), null);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != levelOfImportance.Id)
            {
                return(BadRequest("The Id's do not match"));
            }

            var updatedLevelOfImportance = _levelOfImportanceRepository.UpdateLevelOfImportance(levelOfImportance);

            if (updatedLevelOfImportance == null)
            {
                return(BadRequest("There was a problem updating your record. Please try again"));
            }

            return(Ok($"api/levelOfImportance?id={levelOfImportance.Id}"));
        }
        public IHttpActionResult Insert(LevelOfImportance levelOfImportance)
        {
            _loggerService.CreateLog(_user, "API", "LevelOfImportanceController", "LevelOfImportance", "Insert", levelOfImportance.ToString(), null);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var createdLevelOfImportance = _levelOfImportanceRepository.InsertLevelOfImportance(levelOfImportance);

            if (createdLevelOfImportance == null)
            {
                BadRequest("There was a problem inserting your record. Please try again.");
            }

            return(Created($"api/levelOfImportance?id={createdLevelOfImportance.Id}", createdLevelOfImportance));
        }