public UpInOut DeleteUpInOut(int id)
        {
            UpInOut upInOut = db.UpInOut.Find(id);

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

            try
            {
                db.UpInOut.Remove(upInOut);
                db.SaveChanges();

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

            return(upInOut);
        }
        public UpInOut GetUpInOutById(int id)
        {
            UpInOut upInOut = db.UpInOut.Find(id);

            _loggerService.CreateLog("Jordan", "UpInOut", "Get By Id", id.ToString(), $"Results found: {upInOut != null}");

            return(upInOut);
        }
        public IHttpActionResult GetById(int id)
        {
            _loggerService.CreateLog(_user, "API", "UpInOutController", "UpInOut", "Get By Id", id.ToString(), null);

            UpInOut upInOut = _upInOutRepository.GetUpInOutById(id);

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

            return(Ok(upInOut));
        }
        public UpInOut InsertUpInOut(UpInOut upInOut)
        {
            try
            {
                upInOut.CreatedDateTime = DateTime.Now;
                db.UpInOut.Add(upInOut);
                db.SaveChanges();

                _loggerService.CreateLog("Jordan", "UpInOut", "Create", upInOut.ToString());

                return(upInOut);
            }
            catch (Exception e)
            {
                _loggerService.CreateLog("Jordan", "UpInOut", "Create", upInOut.ToString(), "Error creating this record: " + e.Message);
                return(null);
            }
        }
        public IHttpActionResult Insert(UpInOut upInOut)
        {
            _loggerService.CreateLog(_user, "API", "UpInOutController", "UpInOut", "Insert", upInOut.ToString(), null);

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

            var createdUpInOut = _upInOutRepository.InsertUpInOut(upInOut);

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

            return(Created($"api/upInOut?id={createdUpInOut.Id}", createdUpInOut));
        }
        public UpInOut UpdateUpInOut(UpInOut updatedUpInOut)
        {
            var currentUpInOut = db.UpInOut.Find(updatedUpInOut.Id);

            if (currentUpInOut == null)
            {
                _loggerService.CreateLog("Jordan", "UpInOut", "Update", string.Empty, $"UpInOut {updatedUpInOut.Id} not found to update.");
                return(null);
            }

            if (updatedUpInOut.Name != null)
            {
                currentUpInOut.Name = updatedUpInOut.Name;
            }

            currentUpInOut.Archived         = updatedUpInOut.Archived;
            currentUpInOut.ModifiedDateTime = DateTime.Now;

            db.Entry(currentUpInOut).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException e)
            {
                _loggerService.CreateLog("Jordan", "UpInOut", "Update", currentUpInOut.ToString(), "Error updating upInOut: " + e.Message);
                return(null);
            }
            catch (Exception e)
            {
                _loggerService.CreateLog("Jordan", "UpInOut", "Update", currentUpInOut.ToString(), "Error updating upInOut: " + e.Message);
                return(null);
            }

            _loggerService.CreateLog("Jordan", "UpInOut", "Update", currentUpInOut.ToString());
            return(currentUpInOut);
        }
        public IHttpActionResult Update(int id, UpInOut upInOut)
        {
            _loggerService.CreateLog(_user, "API", "UpInOutController", "UpInOut", "Update", upInOut.ToString(), null);

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

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

            var updatedUpInOut = _upInOutRepository.UpdateUpInOut(upInOut);

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

            return(Ok($"api/upInOut?id={upInOut.Id}"));
        }