public IHttpActionResult EFUpdateUserEmergencyContact(FarmworkersWebAPI.Entities.UserEmergencyContact _userEmergencyContactInformation)
        {
            _context.Configuration.ProxyCreationEnabled = false;

            FarmworkersWebAPI.Entities.UserEmergencyContact _updated = null;

            try
            {
                if (_userEmergencyContactInformation.UserID == 0 && _userEmergencyContactInformation.UserEmergencyContactsID == 0)
                {
                    return(Ok("User Emergency Contact Was Not Updated - User ID and Contact ID are Missing"));
                }

                FarmworkersWebAPI.Entities.UserEmergencyContact original = _context.UserEmergencyContacts.
                                                                           Where(u => u.UserEmergencyContactsID.Equals(_userEmergencyContactInformation.UserEmergencyContactsID)).FirstOrDefault();

                if (original != null)
                {
                    _context.Entry(original).CurrentValues.SetValues(_userEmergencyContactInformation);
                    _context.SaveChanges();

                    _updated = _context.UserEmergencyContacts.
                               Where(u => u.UserEmergencyContactsID.Equals(_userEmergencyContactInformation.UserEmergencyContactsID)).FirstOrDefault();

                    return(Ok(_updated));
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(Ok("User Emergency Contact Was Not Updated - No User Was Found by the ID Provided"));
        }
        public IHttpActionResult EFInsertUserEmergencyContacts(FarmworkersWebAPI.Entities.UserEmergencyContact _userEmergencyContactInformation)
        {
            _context.Configuration.ProxyCreationEnabled = false;

            FarmworkersWebAPI.Entities.UserEmergencyContact _userEmergencyContactData = new FarmworkersWebAPI.Entities.UserEmergencyContact();

            try
            {
                if (_userEmergencyContactInformation.UserID == 0)
                {
                    return(Ok("User Emergency Contact Was Not Added - User ID Missing"));
                }

                if (EFCheckUserExistsController("UserID", _userEmergencyContactInformation.UserID.ToString(), "Yes").FirstOrDefault() == null)
                {
                    return(Ok("User Emergency Contact Was Not Added - No User Was Found by the ID Provided"));
                }

                _userEmergencyContactData = _context.UserEmergencyContacts.Add(_userEmergencyContactInformation);
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(Ok(_userEmergencyContactData));
        }
        public IHttpActionResult EFDeleteUserEmergencyContact(FarmworkersWebAPI.Entities.UserEmergencyContact _userEmergencyContactInformation)
        {
            _context.Configuration.ProxyCreationEnabled = false;

            FarmworkersWebAPI.Entities.UserEmergencyContact _userEmergencyContactData = new FarmworkersWebAPI.Entities.UserEmergencyContact();

            try
            {
                _context.UserEmergencyContacts.Attach(_userEmergencyContactInformation);
                _userEmergencyContactData = _context.UserEmergencyContacts.Remove(_userEmergencyContactInformation);
                _context.SaveChanges();

                return(Ok("User Emergency Contact Deleted Successfully"));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }